diff options
author | scwfri <scwfri@gmail.com> | 2021-11-24 17:31:03 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-30 10:55:19 +0100 |
commit | dbd40e4c2ac321d1975982773f00d32b575a96d9 (patch) | |
tree | a9178723fe414d44e9888856db1c2e6190c40046 | |
parent | e187207610b09b132053d60ef2200bb48c4ccbb2 (diff) | |
download | serenity-dbd40e4c2ac321d1975982773f00d32b575a96d9.zip |
LibGUI: Implement vim motions for LeftBrace and RightBrace
In VimEditingEngine, implemented vim motions for Key_LeftBrace and
Key_RightBrace
-rw-r--r-- | Userland/Libraries/LibGUI/VimEditingEngine.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGUI/VimEditingEngine.cpp b/Userland/Libraries/LibGUI/VimEditingEngine.cpp index 2b991c47ae..d69c3ed326 100644 --- a/Userland/Libraries/LibGUI/VimEditingEngine.cpp +++ b/Userland/Libraries/LibGUI/VimEditingEngine.cpp @@ -971,13 +971,20 @@ bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event) move_one_up(event); switch_to_insert_mode(); return true; - // FIXME: Integrate these into vim motions too. - case (KeyCode::Key_LeftBrace): - move_to_previous_empty_lines_block(); + case (KeyCode::Key_LeftBrace): { + auto amount = m_motion.amount() > 0 ? m_motion.amount() : 1; + m_motion.reset(); + for (int i = 0; i < amount; i++) + move_to_previous_empty_lines_block(); return true; - case (KeyCode::Key_RightBrace): - move_to_next_empty_lines_block(); + } + case (KeyCode::Key_RightBrace): { + auto amount = m_motion.amount() > 0 ? m_motion.amount() : 1; + m_motion.reset(); + for (int i = 0; i < amount; i++) + move_to_next_empty_lines_block(); return true; + } case (KeyCode::Key_J): { // Looks a bit strange, but join without a repeat, with 1 as the repeat or 2 as the repeat all join the current and next lines auto amount = (m_motion.amount() > 2) ? (m_motion.amount() - 1) : 1; |