mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:48:12 +00:00
LibGUI: Fix EditingEngine Shift + Up/Down highlight behavior
Fix unwanted behavior in the EditingEngine where using Shift + Up or Down keys will not highlight to the beginning or end of the first or last lines of the file. Fix issue #15695
This commit is contained in:
parent
edf3aee4df
commit
db2e1bfa02
1 changed files with 15 additions and 0 deletions
|
@ -87,9 +87,24 @@ bool EditingEngine::on_key(KeyEvent const& event)
|
|||
bool const condition_for_up = direction == VerticalDirection::Up && m_editor->cursor().line() > 0;
|
||||
bool const condition_for_down = direction == VerticalDirection::Down && m_editor->cursor().line() < (m_editor->line_count() - 1);
|
||||
|
||||
bool const condition_for_up_to_beginning = direction == VerticalDirection::Up && m_editor->cursor().line() == 0;
|
||||
bool const condition_for_down_to_end = direction == VerticalDirection::Down && m_editor->cursor().line() == (m_editor->line_count() - 1);
|
||||
|
||||
if (condition_for_up || condition_for_down || m_editor->is_wrapping_enabled())
|
||||
m_editor->update_selection(event.shift());
|
||||
|
||||
// Shift + Up on the top line (or only line) selects from the cursor to the start of the line.
|
||||
if (condition_for_up_to_beginning) {
|
||||
m_editor->update_selection(event.shift());
|
||||
move_to_line_beginning();
|
||||
}
|
||||
|
||||
// Shift + Down on the bottom line (or only line) selects from the cursor to the end of the line.
|
||||
if (condition_for_down_to_end) {
|
||||
m_editor->update_selection(event.shift());
|
||||
move_to_line_end();
|
||||
}
|
||||
|
||||
move_one_helper(event, direction);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue