diff options
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java index 5d4918e268..3d7b82fe39 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java @@ -24,6 +24,7 @@ import com.google.devtools.build.lib.events.EventKind; import com.google.devtools.build.lib.pkgcache.LoadingPhaseCompleteEvent; import com.google.devtools.build.lib.util.io.AnsiTerminal; import com.google.devtools.build.lib.util.io.AnsiTerminalWriter; +import com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter; import com.google.devtools.build.lib.util.io.OutErr; import java.io.IOException; @@ -189,7 +190,8 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler { private void addProgressBar() throws IOException { LineCountingAnsiTerminalWriter terminalWriter = new LineCountingAnsiTerminalWriter(terminal); - stateTracker.writeProgressBar(terminalWriter); + stateTracker.writeProgressBar( + new LineWrappingAnsiTerminalWriter(terminalWriter, terminalWidth - 1)); terminalWriter.newline(); numLinesProgressBar = terminalWriter.getWrittenLines(); } @@ -198,7 +200,6 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler { private final AnsiTerminal terminal; private int lineCount; - private int currentLineLength; LineCountingAnsiTerminalWriter(AnsiTerminal terminal) { this.terminal = terminal; @@ -208,7 +209,6 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler { @Override public AnsiTerminalWriter append(String text) throws IOException { terminal.writeString(text); - currentLineLength += text.length(); return this; } @@ -216,11 +216,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler { public AnsiTerminalWriter newline() throws IOException { terminal.cr(); terminal.writeString("\n"); - // Besides the line ended by the newline() command, a line-shift can also happen - // by a string longer than the terminal width being wrapped around; account for - // this as well. - lineCount += 1 + currentLineLength / terminalWidth; - currentLineLength = 0; + lineCount++; return this; } |