Clear prompt on log messages

Printing a new line was not great ux. You might see something like:

[info] set current project to project (in build file:project)
sbt:project>
[info] new client connected: network-1
sbt:project>

instead of initially

[info] set current project to project (in build file:project)
sbt:project>

and then after the client connects:
[info] set current project to project (in build file:project)
[info] new client connected: network-1
sbt:project>
This commit is contained in:
Ethan Atkins 2020-07-21 12:41:53 -07:00
parent 12112741cb
commit 9b332379dd
1 changed files with 3 additions and 3 deletions

View File

@ -80,8 +80,8 @@ private[sbt] final class ProgressState(
private[util] def printPrompt(terminal: Terminal, printStream: PrintStream): Unit =
if (terminal.prompt != Prompt.Running && terminal.prompt != Prompt.Batch) {
val prefix = if (terminal.isAnsiSupported) s"$DeleteLine$CursorLeft1000" else ""
val pmpt = prefix.getBytes ++ terminal.prompt.render().getBytes
pmpt.foreach(b => printStream.write(b & 0xFF))
printStream.write(prefix.getBytes ++ terminal.prompt.render().getBytes)
printStream.flush()
}
private[util] def write(
terminal: Terminal,
@ -93,7 +93,7 @@ private[sbt] final class ProgressState(
if (hasProgress) {
terminal.prompt match {
case a: Prompt.AskUser if a.render.nonEmpty =>
printStream.print(System.lineSeparator + ClearScreenAfterCursor + CursorLeft1000)
printStream.print(DeleteLine + ClearScreenAfterCursor + CursorLeft1000)
printStream.flush()
case _ =>
}