Merge pull request #5898 from eatkins/clear-prompt-fix

Clear prompt only if there are no bytes pending
This commit is contained in:
eugene yokota 2020-09-26 15:47:53 -04:00 committed by GitHub
commit 4ffddfe5ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -72,8 +72,7 @@ private[sbt] final class ProgressState(
if (!lines.endsWith(System.lineSeparator)) {
val allLines = lines.split(System.lineSeparator)
allLines.dropRight(1).foreach(appendLine)
allLines.lastOption
.foreach(currentLineBytes.get ++= _.getBytes("UTF-8"))
allLines.lastOption.foreach(currentLineBytes.get ++= _.getBytes("UTF-8"))
} else if (lines.contains(System.lineSeparator)) {
lines.split(System.lineSeparator).foreach(appendLine)
}
@ -92,11 +91,12 @@ private[sbt] final class ProgressState(
printStream: PrintStream,
hasProgress: Boolean
): Unit = {
val canClearPrompt = currentLineBytes.get.isEmpty
addBytes(terminal, bytes)
if (hasProgress) {
val toWrite = new ArrayBuffer[Byte]
terminal.prompt match {
case a: Prompt.AskUser if a.render.nonEmpty =>
case a: Prompt.AskUser if a.render.nonEmpty && canClearPrompt =>
toWrite ++= (DeleteLine + ClearScreenAfterCursor + CursorLeft1000).getBytes("UTF-8")
case _ =>
}