From 2cf431ee8ac069943013a7f88bb94e31cef66b24 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Fri, 20 Nov 2020 11:32:45 -0800 Subject: [PATCH] Print empty newlines with progress With the latest sbt code, the `last` command displayed all of the output without line separators. This occurred because the logic for appending bytes to System.out split the input bytes on the line separator but if there was nothing but the line separator in the input bytes then the result was empty. --- .../src/main/scala/sbt/internal/util/ProgressState.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 d989d328b..ee58e0762 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 @@ -111,7 +111,10 @@ private[sbt] final class ProgressState( if (appendNewline) toWrite ++= lineSeparatorBytes } parts.dropRight(1).foreach(appendLine(_, true)) - parts.lastOption.foreach(appendLine(_, bytes.endsWith(lineSeparatorBytes))) + parts.lastOption match { + case Some(l) => appendLine(l, bytes.endsWith(lineSeparatorBytes)) + case None => toWrite ++= lineSeparatorBytes + } } else toWrite ++= bytes toWrite ++= clearScreenBytes if (endsWithNewLine) {