Fix intellij import with 1.4.x

The intellij import currentlly works by forking an sbt process and
writing command input through the process input stream. To make this
work, we need the SimpleTerminal (which is used when sbt is run with
-Dsbt.log.noformat=true) to be able to read input.

Attaching the input to the simple terminal caused watch tests to fail on
windows. This can be fixed by checking if the byte read from the input
stream is -1 and ignoring it if so.
This commit is contained in:
Ethan Atkins 2020-08-23 08:52:47 -07:00
parent 02366fdf49
commit 41c33ba92f
2 changed files with 5 additions and 4 deletions

View File

@ -993,6 +993,7 @@ object Terminal {
} }
private[sbt] object NullTerminal extends DefaultTerminal private[sbt] object NullTerminal extends DefaultTerminal
private[sbt] object SimpleTerminal extends DefaultTerminal { private[sbt] object SimpleTerminal extends DefaultTerminal {
override lazy val inputStream: InputStream = nonBlockingIn
override lazy val outputStream: OutputStream = originalOut override lazy val outputStream: OutputStream = originalOut
override lazy val errorStream: OutputStream = originalErr override lazy val errorStream: OutputStream = originalErr
} }

View File

@ -729,7 +729,6 @@ private[sbt] object Continuous extends DeprecatedContinuous {
* to a state where it does not parse an action, we can wait until we receive new input * to a state where it does not parse an action, we can wait until we receive new input
* to attempt to parse again. * to attempt to parse again.
*/ */
type ActionParser = String => Watch.Action
// Transform the Config.watchSettings.inputParser instances to functions of type // Transform the Config.watchSettings.inputParser instances to functions of type
// String => Watch.Action. The String that is provided will contain any characters that // String => Watch.Action. The String that is provided will contain any characters that
// have been read from stdin. If there are any characters available, then it calls the // have been read from stdin. If there are any characters available, then it calls the
@ -766,9 +765,10 @@ private[sbt] object Continuous extends DeprecatedContinuous {
val action = val action =
try { try {
interrupted.set(false) interrupted.set(false)
val byte = terminal.inputStream.read terminal.inputStream.read match {
val parse: ActionParser => Watch.Action = parser => parser(byte.toChar.toString) case -1 => Watch.Ignore
parse(inputHandler) case byte => inputHandler(byte.toChar.toString)
}
} catch { } catch {
case _: InterruptedException => case _: InterruptedException =>
interrupted.set(true) interrupted.set(true)