diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-10-12 19:49:33 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-15 10:38:57 +0200 |
commit | 68884eefc625abc433969b825160b76a26d2390f (patch) | |
tree | 0419ac263544b06f5cfd060a26ac8a81821c8803 /Userland/Libraries/LibGUI/EditingEngine.cpp | |
parent | 2f023acf78e5179cd314ea73da501b03c24f0fd5 (diff) | |
download | serenity-68884eefc625abc433969b825160b76a26d2390f.zip |
LibGUI: Make Ctrl-Shift-Home/-End work again
Previously, the initial call to update_selection() was missing, so if no
text was already selected, then Ctrl-Shift-End would only move the
cursor to the document end, but not select any text.
Diffstat (limited to 'Userland/Libraries/LibGUI/EditingEngine.cpp')
-rw-r--r-- | Userland/Libraries/LibGUI/EditingEngine.cpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/Userland/Libraries/LibGUI/EditingEngine.cpp b/Userland/Libraries/LibGUI/EditingEngine.cpp index 051d6e5b6c..b43721dca2 100644 --- a/Userland/Libraries/LibGUI/EditingEngine.cpp +++ b/Userland/Libraries/LibGUI/EditingEngine.cpp @@ -120,37 +120,29 @@ bool EditingEngine::on_key(const KeyEvent& event) } if (event.key() == KeyCode::Key_Home) { + m_editor->update_selection(event.shift()); if (event.ctrl()) { move_to_first_line(); - if (event.shift() && m_editor->selection().start().is_valid()) { - m_editor->selection().set_end(m_editor->cursor()); - m_editor->did_update_selection(); - } } else { - m_editor->update_selection(event.shift()); move_to_line_beginning(); - if (event.shift() && m_editor->selection().start().is_valid()) { - m_editor->selection().set_end(m_editor->cursor()); - m_editor->did_update_selection(); - } + } + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); + m_editor->did_update_selection(); } return true; } if (event.key() == KeyCode::Key_End) { + m_editor->update_selection(event.shift()); if (event.ctrl()) { move_to_last_line(); - if (event.shift() && m_editor->selection().start().is_valid()) { - m_editor->selection().set_end(m_editor->cursor()); - m_editor->did_update_selection(); - } } else { - m_editor->update_selection(event.shift()); move_to_line_end(); - if (event.shift() && m_editor->selection().start().is_valid()) { - m_editor->selection().set_end(m_editor->cursor()); - m_editor->did_update_selection(); - } + } + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); + m_editor->did_update_selection(); } return true; } |