vim: Fix cgn backwards movement when there is no matches (#10237)

Release Notes:

- Fixed `cgn` backwards movement problem in #9982

There are two issues:

- When there are no more matches, the next repetition still moves the
cursor to the left. After that, the recording is cleared. For this I
simply move the cursor to the right, but it doesn't work when the cursor
is at the end of the line.
- If `cgn` is used when there are no matches, it cleans the previous
recorded actions. Maybe there should be a way to revert the recording.
This also happens when using `c` and `esc`

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
joaquin30 2024-04-08 15:51:36 -05:00 committed by GitHub
parent 0390df27d4
commit f9bf60f017
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 79 additions and 3 deletions

View file

@ -172,6 +172,13 @@ pub(crate) fn repeat(cx: &mut WindowContext, from_insert_mode: bool) {
editor.show_local_selections = false;
})?;
for action in actions {
if !matches!(
cx.update(|cx| Vim::read(cx).workspace_state.replaying),
Ok(true)
) {
break;
}
match action {
ReplayableAction::Action(action) => {
if should_replay(&action) {