Store some vim state per-editor

This fixes a bug where opening and closing command would reset your
selection incorrectly.
This commit is contained in:
Conrad Irwin 2023-08-17 13:35:32 -06:00
parent d308c91020
commit 3514816ece
12 changed files with 106 additions and 48 deletions

View file

@ -41,16 +41,20 @@ pub enum Operator {
FindBackward { after: bool },
}
#[derive(Default)]
pub struct VimState {
#[derive(Default, Clone)]
pub struct EditorState {
pub mode: Mode,
pub last_mode: Mode,
pub operator_stack: Vec<Operator>,
pub search: SearchState,
}
#[derive(Default, Clone)]
pub struct WorkspaceState {
pub search: SearchState,
pub last_find: Option<Motion>,
}
#[derive(Clone)]
pub struct SearchState {
pub direction: Direction,
pub count: usize,
@ -67,7 +71,7 @@ impl Default for SearchState {
}
}
impl VimState {
impl EditorState {
pub fn cursor_shape(&self) -> CursorShape {
match self.mode {
Mode::Normal => {