mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 23:56:06 +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
Notes:
sideshowbarker
2024-07-17 22:55:25 +09:00
Author: https://github.com/skelegorg 🔰
Commit: db2e1bfa02
Pull-request: https://github.com/SerenityOS/serenity/pull/15691
Reviewed-by: https://github.com/linusg
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