Improve vim undo (#9317)
The important change here is to ensure that undo never lands you in visual mode; but we also take care to restore the selection the same way vim does (visual line goes to beginning of line, visual block to the top left, etc.). To help make this behaviour feel right we also group any deletions that started insert mode with the first text inserted. Fixes: #7521 Release Notes: - vim: Improved undo. It will now restore you to normal mode in the same position as vim, and group deletions caused by `c` or `s` with the concomitant insert. ([#7521](https://github.com/zed-industries/zed/issues/7521)).
This commit is contained in:
parent
6ae5274954
commit
bffde43c12
7 changed files with 219 additions and 27 deletions
|
@ -1,8 +1,9 @@
|
|||
use std::{fmt::Display, ops::Range, sync::Arc};
|
||||
|
||||
use collections::HashMap;
|
||||
use editor::Anchor;
|
||||
use gpui::{Action, KeyContext};
|
||||
use language::CursorShape;
|
||||
use language::{CursorShape, Selection, TransactionId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use workspace::searchable::Direction;
|
||||
|
||||
|
@ -66,6 +67,10 @@ pub struct EditorState {
|
|||
pub post_count: Option<usize>,
|
||||
|
||||
pub operator_stack: Vec<Operator>,
|
||||
|
||||
pub current_tx: Option<TransactionId>,
|
||||
pub current_anchor: Option<Selection<Anchor>>,
|
||||
pub undo_modes: HashMap<TransactionId, Mode>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue