diff options
author | Matthew Hall <matthew@quickbeam.me.uk> | 2021-07-13 19:26:14 +0100 |
---|---|---|
committer | Gunnar Beutner <gunnar@beutner.name> | 2021-07-15 10:10:07 +0200 |
commit | 3b5b7c5e6579d31fa3d8ea8debad85e118c78a74 (patch) | |
tree | 3974092ae7f56d9a7759f4f1c9da59def1513ac7 /Userland/Libraries/LibGUI | |
parent | 2653ad36ee37587cd1378d2c51ed4c0b4b3cf24f (diff) | |
download | serenity-3b5b7c5e6579d31fa3d8ea8debad85e118c78a74.zip |
VimEditingEngine: Add support for repeats of J
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/VimEditingEngine.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Userland/Libraries/LibGUI/VimEditingEngine.cpp b/Userland/Libraries/LibGUI/VimEditingEngine.cpp index be97b90893..3cf3354147 100644 --- a/Userland/Libraries/LibGUI/VimEditingEngine.cpp +++ b/Userland/Libraries/LibGUI/VimEditingEngine.cpp @@ -963,13 +963,18 @@ bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event) move_to_next_empty_lines_block(); return true; case (KeyCode::Key_J): { - if (m_editor->cursor().line() + 1 >= m_editor->line_count()) - return true; - move_to_logical_line_end(); - m_editor->add_code_point(' '); - TextPosition next_line = { m_editor->cursor().line() + 1, 0 }; - m_editor->delete_text_range({ m_editor->cursor(), next_line }); - move_one_left(); + // 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; + m_motion.reset(); + for (int i = 0; i < amount; i++) { + if (m_editor->cursor().line() + 1 >= m_editor->line_count()) + return true; + move_to_logical_line_end(); + m_editor->add_code_point(' '); + TextPosition next_line = { m_editor->cursor().line() + 1, 0 }; + m_editor->delete_text_range({ m_editor->cursor(), next_line }); + move_one_left(); + } return true; } case (KeyCode::Key_P): |