mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:07:34 +00:00
LibLine: Correctly handle line content overflow when on last line
Fixes #2525
This commit is contained in:
parent
aa3e440a58
commit
492df51e70
2 changed files with 13 additions and 2 deletions
|
@ -556,7 +556,7 @@ void Editor::handle_read_event()
|
||||||
ctrl_held = false;
|
ctrl_held = false;
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
dbgprintf("Shell: Unhandled final: %02x (%c)\r\n", codepoint, codepoint);
|
dbgprintf("LibLine: Unhandled final: %02x (%c)\r\n", codepoint, codepoint);
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
ctrl_held = false;
|
ctrl_held = false;
|
||||||
continue;
|
continue;
|
||||||
|
@ -984,6 +984,7 @@ void Editor::refresh_display()
|
||||||
swap(previous_num_columns, m_num_columns);
|
swap(previous_num_columns, m_num_columns);
|
||||||
has_cleaned_up = true;
|
has_cleaned_up = true;
|
||||||
}
|
}
|
||||||
|
m_was_resized = false;
|
||||||
}
|
}
|
||||||
// Do not call hook on pure cursor movement.
|
// Do not call hook on pure cursor movement.
|
||||||
if (m_cached_prompt_valid && !m_refresh_needed && m_pending_chars.size() == 0) {
|
if (m_cached_prompt_valid && !m_refresh_needed && m_pending_chars.size() == 0) {
|
||||||
|
@ -992,6 +993,16 @@ void Editor::refresh_display()
|
||||||
m_cached_buffer_size = m_buffer.size();
|
m_cached_buffer_size = m_buffer.size();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// We might be at the last line, and have more than one line;
|
||||||
|
// Refreshing the display will cause the terminal to scroll,
|
||||||
|
// so note that fact and bring origin up.
|
||||||
|
auto current_num_lines = num_lines();
|
||||||
|
if (m_origin_row + current_num_lines > m_num_lines + 1) {
|
||||||
|
if (current_num_lines > m_num_lines)
|
||||||
|
m_origin_row = 0;
|
||||||
|
else
|
||||||
|
m_origin_row = m_num_lines - current_num_lines + 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (on_display_refresh)
|
if (on_display_refresh)
|
||||||
on_display_refresh(*this);
|
on_display_refresh(*this);
|
||||||
|
|
|
@ -250,7 +250,7 @@ private:
|
||||||
|
|
||||||
size_t cursor_line() const
|
size_t cursor_line() const
|
||||||
{
|
{
|
||||||
return (m_drawn_cursor + m_num_columns + current_prompt_length() - 1) / m_num_columns;
|
return (m_drawn_cursor + m_num_columns + current_prompt_length()) / m_num_columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t offset_in_line() const
|
size_t offset_in_line() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue