VimEditingEngine: Add support for repeats of J

This commit is contained in:
Matthew Hall 2021-07-13 19:26:14 +01:00 committed by Gunnar Beutner
parent 2653ad36ee
commit 3b5b7c5e65
Notes: sideshowbarker 2024-07-18 08:59:14 +09:00

View file

@ -963,6 +963,10 @@ bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event)
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;
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();
@ -970,6 +974,7 @@ bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event)
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):