diff options
author | aehlig <aehlig@google.com> | 2017-04-25 17:49:20 +0200 |
---|---|---|
committer | Vladimir Moskva <vladmos@google.com> | 2017-04-25 20:38:59 +0200 |
commit | 5d44a114cba70ff12c3b549c5c90c2ca4dab618c (patch) | |
tree | f93d2a3c56b8e6295f85471be2dc468d9da8c553 | |
parent | 99ea6b466b9562bb720de1ab264687295f7da0e4 (diff) |
When using experimental UI, only to a reset terminal if curses were used
When unregistering an event handler, that uses colors, we need to be sure
to set the terminal in a normal state after unregistering that event handler.
The ExperimentalEventHandler does use curses, however only if options allow
to do so (otherwise, curses will be filtered out by the underlying terminal).
So, we cannot conclude the use of color from the fact that the
ExperimentalEventHandler was in use. Hence when releasing it, only reset the
the terminal, if we did use color and avoid the unnecessary ^[[0m; otherwise.
RELNOTES: None.
PiperOrigin-RevId: 154177220
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java index 26a96d00ab..0e8f86d1a9 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java @@ -538,10 +538,10 @@ public class BlazeCommandDispatcher { System.setOut(savedOut); System.setErr(savedErr); reporter.removeHandler(handler); - releaseHandler(handler); + releaseHandler(handler, eventHandlerOptions); if (!eventHandlerOptions.useColor()) { reporter.removeHandler(ansiAllowingHandler); - releaseHandler(ansiAllowingHandler); + releaseHandler(ansiAllowingHandler, eventHandlerOptions); } env.getTimestampGranularityMonitor().waitForTimestampGranularity(outErr); } @@ -801,13 +801,15 @@ public class BlazeCommandDispatcher { /** * Unsets the event handler. */ - private void releaseHandler(EventHandler eventHandler) { + private void releaseHandler(EventHandler eventHandler, + BlazeCommandEventHandler.Options eventOptions) { if (eventHandler instanceof FancyTerminalEventHandler) { // Make sure that the terminal state of the old event handler is clear // before creating a new one. ((FancyTerminalEventHandler) eventHandler).resetTerminal(); } - if (eventHandler instanceof ExperimentalEventHandler) { + if ((eventHandler instanceof ExperimentalEventHandler) + && (eventOptions.useColor())) { ((ExperimentalEventHandler) eventHandler).resetTerminal(); } } |