mirror of https://github.com/sbt/sbt.git
Use unprompt in watch to better manage ui state
The unprompt method will actually kill the ui thread if its running. If we don't to this, we can get into a weird state where after watch is exited by <enter>, the ask user thread spins up but before it can print the prompt, the terminal prompt is changed to Running, which has an empty prompt. The end result is that jline3 never displays the prompt even though the line reader is active and reading bytes. When the user typed <enter> a prompt would appear. They also could input a command and it would run but it wasn't obvious what would happen since the prompt was missing.
This commit is contained in:
parent
3ddc7bd744
commit
baa96be6dc
|
|
@ -1256,7 +1256,7 @@ private[sbt] object ContinuousCommands {
|
|||
watchState(channel).beforeCommand(state)
|
||||
}
|
||||
private[this] val postWatchCommand = watchCommand(postWatch) { (channel, state) =>
|
||||
StandardMain.exchange.channelForName(channel).foreach(_.terminal.setPrompt(Prompt.Watch))
|
||||
StandardMain.exchange.unprompt(ConsoleUnpromptEvent(Some(CommandSource(channel))), false)
|
||||
val ws = watchState(channel)
|
||||
watchStates.put(channel, ws.withPending(false))
|
||||
ws.afterCommand(state)
|
||||
|
|
@ -1266,7 +1266,7 @@ private[sbt] object ContinuousCommands {
|
|||
state
|
||||
}
|
||||
private[sbt] def stopWatchImpl(channelName: String): Unit = {
|
||||
StandardMain.exchange.channelForName(channelName).foreach(_.terminal.setPrompt(Prompt.Running))
|
||||
StandardMain.exchange.unprompt(ConsoleUnpromptEvent(Some(CommandSource(channelName))), false)
|
||||
Option(watchStates.get(channelName)).foreach { ws =>
|
||||
ws.afterWatch()
|
||||
ws.callbacks.onExit()
|
||||
|
|
|
|||
Loading…
Reference in New Issue