From 9b332379ddb7a3b54a01bc08c97fe300587e488f Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Tue, 21 Jul 2020 12:41:53 -0700 Subject: [PATCH] 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> --- .../src/main/scala/sbt/internal/util/ProgressState.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/util-logging/src/main/scala/sbt/internal/util/ProgressState.scala b/internal/util-logging/src/main/scala/sbt/internal/util/ProgressState.scala index 80b81c543..d27fe9dcd 100644 --- a/internal/util-logging/src/main/scala/sbt/internal/util/ProgressState.scala +++ b/internal/util-logging/src/main/scala/sbt/internal/util/ProgressState.scala @@ -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 _ => }