[Lldb-commits] [lldb] 85a5d0a - [REPL][Windows] Don't redraw the prompt into redirected REPL output (#227755)

via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 30 09:51:45 PDT 2026


Author: Charles Zablit
Date: 2026-09-30T16:51:34Z
New Revision: 85a5d0a53df92dc384058e8738777f81a78a0f69

URL: https://github.com/llvm/llvm-project/commit/85a5d0a53df92dc384058e8738777f81a78a0f69
DIFF: https://github.com/llvm/llvm-project/commit/85a5d0a53df92dc384058e8738777f81a78a0f69.diff

LOG: [REPL][Windows] Don't redraw the prompt into redirected REPL output (#227755)

On Windows without `libedit`, `IOHandlerEditline::PrintAsync` re-printed
the prompt after every async output chunk, even when stdout is not a
console. When REPL output is redirected, as in lit tests, `"> "` lands
in the middle of the program's output, which made `SwiftREPL` tests like
`ExclusivityREPL` flaky.

The prompt is now redrawn only when the handler is interactive and
stdout is a console that can erase it.

Added: 
    

Modified: 
    lldb/source/Core/IOHandler.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index f0dad316cb0fe..99713894f59d4 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -664,12 +664,14 @@ void IOHandlerEditline::PrintAsync(const char *s, size_t len, bool is_stdout) {
 #endif
   {
 #ifdef _WIN32
-    const char *prompt = GetPrompt();
+    const char *prompt = nullptr;
+    CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
+    HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
+    if (GetIsInteractive() &&
+        GetConsoleScreenBufferInfo(console_handle, &screen_buffer_info))
+      prompt = GetPrompt();
     if (prompt) {
       // Back up over previous prompt using Windows API
-      CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
-      HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
-      GetConsoleScreenBufferInfo(console_handle, &screen_buffer_info);
       COORD coord = screen_buffer_info.dwCursorPosition;
       coord.X -= strlen(prompt);
       if (coord.X < 0)


        


More information about the lldb-commits mailing list