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

@ -3,10 +3,11 @@ use editor::{scroll::Autoscroll, Bias, Editor};
use gpui::{actions, Action, ViewContext};
use language::SelectionGoal;
actions!(vim, [NormalBefore]);
actions!(vim, [NormalBefore, TemporaryNormal]);
pub fn register(editor: &mut Editor, cx: &mut ViewContext<Vim>) {
Vim::action(editor, cx, Vim::normal_before);
Vim::action(editor, cx, Vim::temporary_normal);
}
impl Vim {
@ -35,6 +36,11 @@ impl Vim {
self.repeat(true, cx)
}
fn temporary_normal(&mut self, _: &TemporaryNormal, cx: &mut ViewContext<Self>) {
self.switch_mode(Mode::Normal, true, cx);
self.temp_mode = true;
}
}
#[cfg(test)]