mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
VimEditingEngine: Add support for repeats of J
This commit is contained in:
parent
2653ad36ee
commit
3b5b7c5e65
Notes:
sideshowbarker
2024-07-18 08:59:14 +09:00
Author: https://github.com/mattyhall Commit: https://github.com/SerenityOS/serenity/commit/3b5b7c5e657 Pull-request: https://github.com/SerenityOS/serenity/pull/8622
1 changed files with 12 additions and 7 deletions
|
@ -963,13 +963,18 @@ bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event)
|
||||||
move_to_next_empty_lines_block();
|
move_to_next_empty_lines_block();
|
||||||
return true;
|
return true;
|
||||||
case (KeyCode::Key_J): {
|
case (KeyCode::Key_J): {
|
||||||
if (m_editor->cursor().line() + 1 >= m_editor->line_count())
|
// 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
|
||||||
return true;
|
auto amount = (m_motion.amount() > 2) ? (m_motion.amount() - 1) : 1;
|
||||||
move_to_logical_line_end();
|
m_motion.reset();
|
||||||
m_editor->add_code_point(' ');
|
for (int i = 0; i < amount; i++) {
|
||||||
TextPosition next_line = { m_editor->cursor().line() + 1, 0 };
|
if (m_editor->cursor().line() + 1 >= m_editor->line_count())
|
||||||
m_editor->delete_text_range({ m_editor->cursor(), next_line });
|
return true;
|
||||||
move_one_left();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
case (KeyCode::Key_P):
|
case (KeyCode::Key_P):
|
||||||
|
|
Loading…
Reference in a new issue