vim: Allow count and repeat for "r" and "shift-r" action (#13287)

Fixing the "r" action just involved adapting `normal_replace` to replace
multiple characters.

Fixing the "shift-r" command was less straightforward. The bindings for
`vim::BeforeNormal` in replace mode were being overwritten and several
other steps required for action repetition were not performed. Finally,
the cursor adjustment after re-entering normal mode was duplicated
(`vim::BeforeNormal` was now triggered correctly) so I removed the
special case for replace mode.

Release Notes:

- Fixed vim "r" action to accept a count argument
- Fixed vim "shift-r" action to accept a count argument and allow
repetition

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Benjamin Davies 2024-06-25 03:41:33 +12:00 committed by GitHub
parent 77b2da2b42
commit dea928b00c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 109 additions and 10 deletions

View file

@ -421,7 +421,7 @@ impl Vim {
state.current_tx.take();
state.current_anchor.take();
});
if mode != Mode::Insert {
if mode != Mode::Insert && mode != Mode::Replace {
self.take_count(cx);
}
@ -488,11 +488,6 @@ impl Vim {
if selection.is_empty() {
selection.end = movement::right(map, selection.start);
}
} else if last_mode == Mode::Replace {
if selection.head().column() != 0 {
let point = movement::left(map, selection.head());
selection.collapse_to(point, selection.goal)
}
}
});
})