Skip to content

Commit

Permalink
fix e behavior in operator-pending mode of vim example
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
rhysd committed Aug 3, 2024
1 parent 6f5ca38 commit 9087e75
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions examples/vim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9087e75

Please sign in to comment.