mirror of https://github.com/sbt/sbt.git
Revert "Unprompt channels during project load"
This reverts commitb1dcf031a5. I found thatb1dcf031a5had some unintended consequences that seemed to mess up the prompt state. The real problem that it was trying to address was that the prompt was being interleaved with log messages in some scenarios. There was a different way to fix that in ProgressState that was both simpler and more reliable.
This commit is contained in:
parent
901c8ee5df
commit
12112741cb
|
|
@ -90,7 +90,7 @@ private[sbt] final class ProgressState(
|
|||
hasProgress: Boolean
|
||||
): Unit = {
|
||||
addBytes(terminal, bytes)
|
||||
if (hasProgress && terminal.prompt != Prompt.Loading) {
|
||||
if (hasProgress) {
|
||||
terminal.prompt match {
|
||||
case a: Prompt.AskUser if a.render.nonEmpty =>
|
||||
printStream.print(System.lineSeparator + ClearScreenAfterCursor + CursorLeft1000)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,5 @@ private[sbt] object Prompt {
|
|||
private[sbt] case object Running extends NoPrompt
|
||||
private[sbt] case object Batch extends NoPrompt
|
||||
private[sbt] case object Watch extends NoPrompt
|
||||
private[sbt] case object Loading extends NoPrompt
|
||||
private[sbt] case object NoPrompt extends NoPrompt
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.util.concurrent.Executors
|
|||
|
||||
import sbt.State
|
||||
import sbt.internal.util.{ ConsoleAppender, ProgressEvent, ProgressState, Util }
|
||||
import sbt.internal.util.Prompt.{ AskUser, Loading, Running }
|
||||
import sbt.internal.util.Prompt.{ AskUser, Running }
|
||||
|
||||
private[sbt] class UserThread(val channel: CommandChannel) extends AutoCloseable {
|
||||
private[this] val uiThread = new AtomicReference[(UITask, Thread)]
|
||||
|
|
@ -70,9 +70,8 @@ private[sbt] class UserThread(val channel: CommandChannel) extends AutoCloseable
|
|||
}
|
||||
val state = consolePromptEvent.state
|
||||
terminal.prompt match {
|
||||
case Loading | Running =>
|
||||
terminal.setPrompt(AskUser(() => UITask.shellPrompt(terminal, state)))
|
||||
case _ =>
|
||||
case Running => terminal.setPrompt(AskUser(() => UITask.shellPrompt(terminal, state)))
|
||||
case _ =>
|
||||
}
|
||||
onProgressEvent(ProgressEvent("Info", Vector(), None, None, None))
|
||||
reset(state)
|
||||
|
|
|
|||
|
|
@ -916,8 +916,6 @@ object BuiltinCommands {
|
|||
}
|
||||
|
||||
def doLoadProject(s0: State, action: LoadAction.Value): State = {
|
||||
StandardMain.exchange.unprompt(ConsoleUnpromptEvent(None), force = true)
|
||||
StandardMain.exchange.channels.foreach(_.terminal.setPrompt(Prompt.Loading))
|
||||
welcomeBanner(s0)
|
||||
checkSBTVersionChanged(s0)
|
||||
val (s1, base) = Project.loadAction(SessionVar.clear(s0), action)
|
||||
|
|
@ -938,9 +936,7 @@ object BuiltinCommands {
|
|||
SessionSettings.checkSession(session, s2)
|
||||
val s3 = addCacheStoreFactoryFactory(Project.setProject(session, structure, s2))
|
||||
val s4 = setupGlobalFileTreeRepository(s3)
|
||||
val s5 = CheckBuildSources.init(LintUnused.lintUnusedFunc(s4))
|
||||
StandardMain.exchange.prompt(ConsolePromptEvent(s5))
|
||||
s5
|
||||
CheckBuildSources.init(LintUnused.lintUnusedFunc(s4))
|
||||
}
|
||||
|
||||
private val setupGlobalFileTreeRepository: State => State = { state =>
|
||||
|
|
@ -984,11 +980,9 @@ object BuiltinCommands {
|
|||
val exchange = StandardMain.exchange
|
||||
if (exchange.channels.exists(ContinuousCommands.isInWatch)) {
|
||||
val s1 = exchange.run(s0)
|
||||
def needPrompt(c: CommandChannel) =
|
||||
ContinuousCommands.isInWatch(c) && !ContinuousCommands.isPending(c)
|
||||
exchange.channels.foreach {
|
||||
case c if needPrompt(c) => c.prompt(ConsolePromptEvent(s1))
|
||||
case _ =>
|
||||
case c if ContinuousCommands.isPending(c) =>
|
||||
case c => c.prompt(ConsolePromptEvent(s1))
|
||||
}
|
||||
val exec: Exec = getExec(s1, Duration.Inf)
|
||||
val remaining: List[Exec] =
|
||||
|
|
|
|||
|
|
@ -198,9 +198,9 @@ object MainLoop {
|
|||
state.put(sbt.Keys.currentTaskProgress, new Keys.TaskProgress(progress))
|
||||
} else state
|
||||
}
|
||||
exchange.setState(progressState)
|
||||
exchange.setExec(Some(exec))
|
||||
exchange.unprompt(ConsoleUnpromptEvent(exec.source), force = false)
|
||||
StandardMain.exchange.setState(progressState)
|
||||
StandardMain.exchange.setExec(Some(exec))
|
||||
StandardMain.exchange.unprompt(ConsoleUnpromptEvent(exec.source))
|
||||
val newState = Command.process(exec.commandLine, progressState)
|
||||
if (exec.execId.fold(true)(!_.startsWith(networkExecPrefix)) &&
|
||||
!exec.commandLine.startsWith(networkExecPrefix)) {
|
||||
|
|
|
|||
|
|
@ -357,11 +357,7 @@ private[sbt] final class CommandExchange {
|
|||
case c => c.prompt(event)
|
||||
}
|
||||
}
|
||||
def unprompt(event: ConsoleUnpromptEvent, force: Boolean): Unit = {
|
||||
if (force)
|
||||
channels.foreach(c => c.unprompt(event.copy(lastSource = Some(CommandSource(c.name)))))
|
||||
else channels.foreach(_.unprompt(event))
|
||||
}
|
||||
def unprompt(event: ConsoleUnpromptEvent): Unit = channels.foreach(_.unprompt(event))
|
||||
|
||||
def logMessage(event: LogEvent): Unit = {
|
||||
channels.foreach {
|
||||
|
|
|
|||
|
|
@ -1254,11 +1254,11 @@ private[sbt] object ContinuousCommands {
|
|||
}
|
||||
|
||||
private[this] val preWatchCommand = watchCommand(preWatch) { (channel, state) =>
|
||||
StandardMain.exchange.channelForName(channel).foreach(_.terminal.setPrompt(Prompt.Running))
|
||||
StandardMain.exchange.channelForName(channel).foreach(_.terminal.setPrompt(Prompt.Watch))
|
||||
watchState(channel).beforeCommand(state)
|
||||
}
|
||||
private[this] val postWatchCommand = watchCommand(postWatch) { (channel, state) =>
|
||||
StandardMain.exchange.unprompt(ConsoleUnpromptEvent(Some(CommandSource(channel))), false)
|
||||
StandardMain.exchange.unprompt(ConsoleUnpromptEvent(Some(CommandSource(channel))))
|
||||
val ws = watchState(channel)
|
||||
watchStates.put(channel, ws.withPending(false))
|
||||
ws.afterCommand(state)
|
||||
|
|
@ -1268,7 +1268,7 @@ private[sbt] object ContinuousCommands {
|
|||
state
|
||||
}
|
||||
private[sbt] def stopWatchImpl(channelName: String): Unit = {
|
||||
StandardMain.exchange.unprompt(ConsoleUnpromptEvent(Some(CommandSource(channelName))), false)
|
||||
StandardMain.exchange.unprompt(ConsoleUnpromptEvent(Some(CommandSource(channelName))))
|
||||
Option(watchStates.get(channelName)).foreach { ws =>
|
||||
ws.afterWatch()
|
||||
ws.callbacks.onExit()
|
||||
|
|
|
|||
Loading…
Reference in New Issue