From 9087e75c1fa4ffc5cc0ad83bec669bb6712c686b Mon Sep 17 00:00:00 2001 From: rhysd Date: Sat, 3 Aug 2024 23:06:40 +0900 Subject: [PATCH] fix `e` behavior in operator-pending mode of `vim` example `e`'s behavior is actually not same as `w`. For example, let's say we have the following text and the cursor is on 'f'. ``` foo bar ``` Then `de` deletes the text 'foo' but `dw` deletes the text 'foo ' including the trailing space. --- examples/vim.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/vim.rs b/examples/vim.rs index 0e22edb..e888b20 100644 --- a/examples/vim.rs +++ b/examples/vim.rs @@ -116,14 +116,12 @@ impl Vim { key: Key::Char('e'), ctrl: false, .. - } if matches!(self.mode, Mode::Operator(_)) => { - textarea.move_cursor(CursorMove::WordForward) // `e` behaves like `w` in operator-pending mode + } => { + textarea.move_cursor(CursorMove::WordEnd); + if matches!(self.mode, Mode::Operator(_)) { + textarea.move_cursor(CursorMove::Forward); // Include the text under the cursor + } } - Input { - key: Key::Char('e'), - ctrl: false, - .. - } => textarea.move_cursor(CursorMove::WordEnd), Input { key: Key::Char('b'), ctrl: false,