Skip to content

Commit c103d61

Browse files
authored
[lldb] Fix a bug when disabling the statusline. (#169127)
Currently, disabling the statusline with `settings set show-statusline false` leaves LLDB in a broken state. The same is true when trying to toggle the setting again. The issue was that setting the scroll window to 0 is apparently not identical to setting it to the correct number of rows, even though some documentation online incorrectly claims so. Fixes #166608
1 parent c9d9ddd commit c103d61

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lldb/source/Core/Statusline.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void Statusline::UpdateScrollWindow(ScrollWindowMode mode) {
9191
if (!stream_sp)
9292
return;
9393

94-
const unsigned reduced_scroll_window = m_terminal_height - 1;
94+
const unsigned reduced_scroll_rows = m_terminal_height - 1;
9595
LockedStreamFile locked_stream = stream_sp->Lock();
9696

9797
switch (mode) {
@@ -101,13 +101,14 @@ void Statusline::UpdateScrollWindow(ScrollWindowMode mode) {
101101
locked_stream.Printf(ANSI_UP_ROWS, 1);
102102
// Reduce the scroll window.
103103
locked_stream << ANSI_SAVE_CURSOR;
104-
locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_window);
104+
locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_rows);
105105
locked_stream << ANSI_RESTORE_CURSOR;
106106
break;
107107
case DisableStatusline:
108108
// Reset the scroll window.
109109
locked_stream << ANSI_SAVE_CURSOR;
110-
locked_stream.Printf(ANSI_SET_SCROLL_ROWS, 0);
110+
locked_stream.Printf(ANSI_SET_SCROLL_ROWS,
111+
static_cast<unsigned>(m_terminal_height));
111112
locked_stream << ANSI_RESTORE_CURSOR;
112113
// Clear the screen below to hide the old statusline.
113114
locked_stream << ANSI_CLEAR_BELOW;
@@ -116,7 +117,7 @@ void Statusline::UpdateScrollWindow(ScrollWindowMode mode) {
116117
// Clear the screen and update the scroll window.
117118
// FIXME: Find a better solution (#146919).
118119
locked_stream << ANSI_CLEAR_SCREEN;
119-
locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_window);
120+
locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_rows);
120121
break;
121122
}
122123

lldb/test/API/functionalities/statusline/TestStatusline.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ def test(self):
7171
)
7272
self.expect('set set separator "| "')
7373

74-
# Hide the statusline and check or the control character.
75-
self.expect("set set show-statusline false", ["\x1b[1;0r"])
74+
# Hide the statusline and check for the control character.
75+
self.expect(
76+
"set set show-statusline false", ["\x1b[1;{}r".format(self.TERMINAL_HEIGHT)]
77+
)
7678

7779
def test_no_color(self):
7880
"""Basic test for the statusline with colors disabled."""

0 commit comments

Comments
 (0)