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

@ -176,7 +176,7 @@ impl Vim {
.0;
}
cursor = movement::indented_line_beginning(map, cursor, true);
} else if !is_multiline {
} else if !is_multiline && !vim.temp_mode {
cursor = movement::saturating_left(map, cursor)
}
cursors.push(cursor);

View file

@ -3,6 +3,7 @@ use std::{cell::RefCell, rc::Rc};
use crate::{
insert::NormalBefore,
motion::Motion,
normal::InsertBefore,
state::{Mode, Operator, RecordedSelection, ReplayableAction, VimGlobals},
Vim,
};
@ -308,6 +309,11 @@ impl Vim {
actions.push(ReplayableAction::Action(EndRepeat.boxed_clone()));
if self.temp_mode {
self.temp_mode = false;
actions.push(ReplayableAction::Action(InsertBefore.boxed_clone()));
}
let globals = Vim::globals(cx);
globals.dot_replaying = true;
let mut replayer = globals.replayer.get_or_insert_with(Replayer::new).clone();

View file

@ -139,6 +139,11 @@ impl Vim {
options |= SearchOptions::REGEX;
}
search_bar.set_search_options(options, cx);
let prior_mode = if self.temp_mode {
Mode::Insert
} else {
self.mode
};
self.search = SearchState {
direction,
@ -146,7 +151,7 @@ impl Vim {
initial_query: query,
prior_selections,
prior_operator: self.operator_stack.last().cloned(),
prior_mode: self.mode,
prior_mode,
}
});
}

View file

@ -42,6 +42,7 @@ impl Vim {
});
});
});
self.exit_temporary_normal(cx);
}
pub fn yank_object(&mut self, object: Object, around: bool, cx: &mut ViewContext<Self>) {
@ -65,6 +66,7 @@ impl Vim {
});
});
});
self.exit_temporary_normal(cx);
}
pub fn yank_selections_content(