1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:37:34 +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:
AnotherTest 2020-04-10 09:35:53 +04:30 committed by Andreas Kling
parent 870936085a
commit 1b422315fa

View file

@ -203,17 +203,27 @@ String Editor::get_line(const String& prompt)
case 'A': // up
if (m_history_cursor > 0)
--m_history_cursor;
clear_line();
if (m_history_cursor < m_history.size())
insert(m_history[m_history_cursor]);
if (m_history_cursor < m_history.size()) {
auto& line = 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;
continue;
case 'B': // down
if (m_history_cursor < m_history.size())
++m_history_cursor;
clear_line();
if (m_history_cursor < m_history.size())
insert(m_history[m_history_cursor]);
if (m_history_cursor < m_history.size()) {
auto& line = 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;
continue;
case 'D': // left