Skip to content

Commit ca0866b

Browse files
authored
[LLDB][Editline] empty current line before el_wgets (#165830)
This PR fixes #157637 by printing ANSI sequence "\r\x1b[K" to empty the line before calling to `el_wgets`. Later when `el_wgets` prints the real prompt, all wrongly printed characters are removed from the terminal.
1 parent 0e46b41 commit ca0866b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lldb/source/Host/common/Editline.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,9 @@ bool Editline::GetLine(std::string &line, bool &interrupted) {
16261626
m_editor_status = EditorStatus::Editing;
16271627
m_revert_cursor_index = -1;
16281628

1629+
lldbassert(m_output_stream_sp);
1630+
fprintf(m_locked_output->GetFile().GetStream(), "\r" ANSI_CLEAR_RIGHT);
1631+
16291632
int count;
16301633
auto input = el_wgets(m_editline, &count);
16311634

lldb/test/API/terminal/TestEditline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_prompt_no_color(self):
9494
# after the prompt.
9595
self.child.send("foo")
9696
# Check that there are no escape codes.
97-
self.child.expect(re.escape("\n(lldb) foo"))
97+
self.child.expect(re.escape("\n\r\x1b[K(lldb) foo"))
9898

9999
@skipIfAsan
100100
@skipIfEditlineSupportMissing

0 commit comments

Comments
 (0)