mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:57:36 +00:00
LibLine: Fix regression with moving around in history misplacing cursor
This commit fixes a regression where the prompt would not be cleared upon substitution of lines from the history
This commit is contained in:
parent
870936085a
commit
1b422315fa
1 changed files with 16 additions and 6 deletions
|
@ -203,17 +203,27 @@ String Editor::get_line(const String& prompt)
|
||||||
case 'A': // up
|
case 'A': // up
|
||||||
if (m_history_cursor > 0)
|
if (m_history_cursor > 0)
|
||||||
--m_history_cursor;
|
--m_history_cursor;
|
||||||
clear_line();
|
if (m_history_cursor < m_history.size()) {
|
||||||
if (m_history_cursor < m_history.size())
|
auto& line = m_history[m_history_cursor];
|
||||||
insert(m_history[m_history_cursor]);
|
m_buffer.clear();
|
||||||
|
for (auto& c : line)
|
||||||
|
m_buffer.append(c);
|
||||||
|
m_cursor = m_buffer.size();
|
||||||
|
m_refresh_needed = true;
|
||||||
|
}
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
continue;
|
continue;
|
||||||
case 'B': // down
|
case 'B': // down
|
||||||
if (m_history_cursor < m_history.size())
|
if (m_history_cursor < m_history.size())
|
||||||
++m_history_cursor;
|
++m_history_cursor;
|
||||||
clear_line();
|
if (m_history_cursor < m_history.size()) {
|
||||||
if (m_history_cursor < m_history.size())
|
auto& line = m_history[m_history_cursor];
|
||||||
insert(m_history[m_history_cursor]);
|
m_buffer.clear();
|
||||||
|
for (auto& c : line)
|
||||||
|
m_buffer.append(c);
|
||||||
|
m_cursor = m_buffer.size();
|
||||||
|
m_refresh_needed = true;
|
||||||
|
}
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
continue;
|
continue;
|
||||||
case 'D': // left
|
case 'D': // left
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue