mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibGUI: Add Ctrl-W to insert mode
In Vim's insert mode, Ctrl-W deletes the word before the cursor, like Ctrl-Backspace. Unlike Ctrl-Backspace, if only whitespace exists between the end of the word and the cursor, the word will be deleted with the whitespace. To do so, this commit introduces two methods: delete_previous_word() for TextEditor and first_word_before() for TextDocument, where the former depends on the latter. delete_previous_word() is then called in VimEditingEngine.
This commit is contained in:
committed by
Gunnar Beutner
parent
8f01a8b741
commit
808e5e813f
@@ -883,6 +883,12 @@ void TextEditor::keydown_event(KeyEvent& event)
|
||||
event.ignore();
|
||||
}
|
||||
|
||||
void TextEditor::delete_previous_word()
|
||||
{
|
||||
TextRange to_erase(document().first_word_before(m_cursor, true), m_cursor);
|
||||
execute<RemoveTextCommand>(document().text_in_range(to_erase), to_erase);
|
||||
}
|
||||
|
||||
void TextEditor::delete_current_line()
|
||||
{
|
||||
if (has_selection())
|
||||
|
||||
Reference in New Issue
Block a user