mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
VimEditingEngine: Operate on real lines rather than wrapped ones
In the normal editing engine keys like Home, End etc work on visual lines, but vim operates on real ones. Eg if you have a really long line and wrapping is on then in normal editing Home would take you to the beginning of the wrapped line, but 'I' would put you insert mode at the beginning of the real line in vim.
This commit is contained in:
parent
5d1676b05a
commit
a7e7f62d08
Notes:
sideshowbarker
2024-07-18 08:59:31 +09:00
Author: https://github.com/mattyhall 🔰
Commit: a7e7f62d08
Pull-request: https://github.com/SerenityOS/serenity/pull/8622
3 changed files with 34 additions and 24 deletions
|
@ -834,10 +834,10 @@ bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event)
|
|||
delete_line();
|
||||
if (was_second_last_line || (m_editor->cursor().line() != 0 && m_editor->cursor().line() != m_editor->line_count() - 1)) {
|
||||
move_one_up(event);
|
||||
move_to_line_end();
|
||||
move_to_logical_line_end();
|
||||
m_editor->add_code_point(0x0A);
|
||||
} else if (m_editor->cursor().line() == 0) {
|
||||
move_to_line_beginning();
|
||||
move_to_logical_line_beginning();
|
||||
m_editor->add_code_point(0x0A);
|
||||
move_one_up(event);
|
||||
} else if (m_editor->cursor().line() == m_editor->line_count() - 1) {
|
||||
|
@ -896,15 +896,15 @@ bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event)
|
|||
if (event.shift() && !event.ctrl() && !event.alt()) {
|
||||
switch (event.key()) {
|
||||
case (KeyCode::Key_A):
|
||||
move_to_line_end();
|
||||
move_to_logical_line_end();
|
||||
switch_to_insert_mode();
|
||||
return true;
|
||||
case (KeyCode::Key_I):
|
||||
move_to_line_beginning();
|
||||
move_to_logical_line_beginning();
|
||||
switch_to_insert_mode();
|
||||
return true;
|
||||
case (KeyCode::Key_O):
|
||||
move_to_line_beginning();
|
||||
move_to_logical_line_beginning();
|
||||
m_editor->add_code_point(0x0A);
|
||||
move_one_up(event);
|
||||
switch_to_insert_mode();
|
||||
|
@ -958,7 +958,7 @@ bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event)
|
|||
switch_to_insert_mode();
|
||||
return true;
|
||||
case (KeyCode::Key_O):
|
||||
move_to_line_end();
|
||||
move_to_logical_line_end();
|
||||
m_editor->add_code_point(0x0A);
|
||||
switch_to_insert_mode();
|
||||
return true;
|
||||
|
@ -1043,11 +1043,11 @@ bool VimEditingEngine::on_key_in_visual_mode(const KeyEvent& event)
|
|||
if (event.shift() && !event.ctrl() && !event.alt()) {
|
||||
switch (event.key()) {
|
||||
case (KeyCode::Key_A):
|
||||
move_to_line_end();
|
||||
move_to_logical_line_end();
|
||||
switch_to_insert_mode();
|
||||
return true;
|
||||
case (KeyCode::Key_I):
|
||||
move_to_line_beginning();
|
||||
move_to_logical_line_beginning();
|
||||
switch_to_insert_mode();
|
||||
return true;
|
||||
default:
|
||||
|
@ -1230,7 +1230,7 @@ void VimEditingEngine::yank(TextRange range)
|
|||
void VimEditingEngine::put()
|
||||
{
|
||||
if (m_yank_type == YankType::Line) {
|
||||
move_to_line_end();
|
||||
move_to_logical_line_end();
|
||||
StringBuilder sb = StringBuilder(m_yank_buffer.length() + 1);
|
||||
sb.append_code_point(0x0A);
|
||||
sb.append(m_yank_buffer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue