Skip to content

Commit

Permalink
fix vim example's text selection should be inclusive in visual mode
Browse files Browse the repository at this point in the history
Vim's text selection is inclusive. For example, when a cursor is on 'r'
of 'bar', 'r' is included in the selection. However tui-textarea's text
selection is exclusive on the end of the range. Move cursor forward to
emulate Vim's behavior better.
  • Loading branch information
rhysd committed Aug 1, 2024
1 parent 76f1ab6 commit 60943f8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/vim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ impl Vim {
ctrl: false,
..
} if self.mode == Mode::Visual => {
textarea.move_cursor(CursorMove::Forward); // Vim's text selection is inclusive
textarea.copy();
return Transition::Mode(Mode::Normal);
}
Expand All @@ -346,6 +347,7 @@ impl Vim {
ctrl: false,
..
} if self.mode == Mode::Visual => {
textarea.move_cursor(CursorMove::Forward); // Vim's text selection is inclusive
textarea.cut();
return Transition::Mode(Mode::Normal);
}
Expand All @@ -354,6 +356,7 @@ impl Vim {
ctrl: false,
..
} if self.mode == Mode::Visual => {
textarea.move_cursor(CursorMove::Forward); // Vim's text selection is inclusive
textarea.cut();
return Transition::Mode(Mode::Insert);
}
Expand Down

0 comments on commit 60943f8

Please sign in to comment.