From bfd15a572ebbc852709d9cf25368d5314dc96377 Mon Sep 17 00:00:00 2001 From: Evgenii Novozhilov Date: Tue, 17 Dec 2024 14:32:38 +0200 Subject: [PATCH] fixed bug where bazel runs with curses when using the old sync view (#7139) The old sync view does not use a pty based terminal and cannot handle bazel output correctly when it runs with curses. (cherry picked from commit 0fb3f8107480cd57b69f30dd357826eed02ca13b) --- .../idea/blaze/base/buildview/BazelExecService.kt | 10 +++++++--- .../google/idea/blaze/base/toolwindow/ConsoleView.java | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/base/src/com/google/idea/blaze/base/buildview/BazelExecService.kt b/base/src/com/google/idea/blaze/base/buildview/BazelExecService.kt index 850f5be1bc4..82f63330a7f 100644 --- a/base/src/com/google/idea/blaze/base/buildview/BazelExecService.kt +++ b/base/src/com/google/idea/blaze/base/buildview/BazelExecService.kt @@ -66,7 +66,12 @@ class BazelExecService(private val project: Project) : Disposable { } private suspend fun execute(ctx: BlazeContext, cmdBuilder: BlazeCommand.Builder): Int { - val cmd = cmdBuilder.apply { addBlazeFlags("--curses=yes") }.build() + // the old sync view does not use a PTY based terminal + if (BuildViewMigration.present(ctx)) { + cmdBuilder.addBlazeFlags("--curses=yes") + } + + val cmd = cmdBuilder.build() val root = cmd.effectiveWorkspaceRoot.orElseGet { WorkspaceRoot.fromProject(project).path() } val size = BuildViewScope.of(ctx)?.consoleSize ?: PtyConsoleView.DEFAULT_SIZE @@ -182,5 +187,4 @@ class BazelExecService(private val project: Project) : Disposable { } } } -} - +} \ No newline at end of file diff --git a/base/src/com/google/idea/blaze/base/toolwindow/ConsoleView.java b/base/src/com/google/idea/blaze/base/toolwindow/ConsoleView.java index aa2d4272281..30ecf184f17 100644 --- a/base/src/com/google/idea/blaze/base/toolwindow/ConsoleView.java +++ b/base/src/com/google/idea/blaze/base/toolwindow/ConsoleView.java @@ -237,6 +237,10 @@ void println(PrintOutput output) { } private void println(String text, OutputType outputType) { + if (outputType == OutputType.PROCESS) { + text = text.stripTrailing(); + } + ansiEscapeDecoder.escapeText( text, outputType == OutputType.ERROR ? ProcessOutputTypes.STDERR : ProcessOutputTypes.STDOUT,