vim: Add support for temporary normal mode (ctrl-o) within insert mode (#19454)

Support has been added for the ctrl-o command within insert mode. Ctrl-o
is used to partially enter normal mode for 1 motion to then return back
into insert mode.

Release Notes:

- vim: Added support for `ctrl-o` in insert mode to enter temporary
normal mode

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Axel Carlsson 2024-11-13 20:44:41 +01:00 committed by GitHub
parent 254ce74036
commit b1cd9e4d24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 145 additions and 11 deletions

View file

@ -153,6 +153,7 @@ pub struct VimGlobals {
pub stop_recording_after_next_action: bool,
pub ignore_current_insertion: bool,
pub recorded_count: Option<usize>,
pub recording_actions: Vec<ReplayableAction>,
pub recorded_actions: Vec<ReplayableAction>,
pub recorded_selection: RecordedSelection,
@ -339,11 +340,12 @@ impl VimGlobals {
pub fn observe_action(&mut self, action: Box<dyn Action>) {
if self.dot_recording {
self.recorded_actions
self.recording_actions
.push(ReplayableAction::Action(action.boxed_clone()));
if self.stop_recording_after_next_action {
self.dot_recording = false;
self.recorded_actions = std::mem::take(&mut self.recording_actions);
self.stop_recording_after_next_action = false;
}
}
@ -363,12 +365,13 @@ impl VimGlobals {
return;
}
if self.dot_recording {
self.recorded_actions.push(ReplayableAction::Insertion {
self.recording_actions.push(ReplayableAction::Insertion {
text: text.clone(),
utf16_range_to_replace: range_to_replace.clone(),
});
if self.stop_recording_after_next_action {
self.dot_recording = false;
self.recorded_actions = std::mem::take(&mut self.recording_actions);
self.stop_recording_after_next_action = false;
}
}