vim: Add basic mark support (#11507)
Release Notes: - vim: Added support for buffer-local marks (`'a-'z`) and some builtin marks `'<`,`'>`,`'[`,`']`, `'{`, `'}` and `^`. Global marks (`'A-'Z`), and other builtin marks (`'0-'9`, `'(`, `')`, `''`, `'.`, `'"`) are not yet implemented. (#5122) --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
9cef0ac869
commit
901cb8b3d2
14 changed files with 471 additions and 6 deletions
|
@ -59,6 +59,8 @@ pub enum Operator {
|
|||
AddSurrounds { target: Option<SurroundsType> },
|
||||
ChangeSurrounds { target: Option<Object> },
|
||||
DeleteSurrounds,
|
||||
Mark,
|
||||
Jump { line: bool },
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
|
@ -74,6 +76,8 @@ pub struct EditorState {
|
|||
pub operator_stack: Vec<Operator>,
|
||||
pub replacements: Vec<(Range<editor::Anchor>, String)>,
|
||||
|
||||
pub marks: HashMap<String, Vec<Anchor>>,
|
||||
|
||||
pub current_tx: Option<TransactionId>,
|
||||
pub current_anchor: Option<Selection<Anchor>>,
|
||||
pub undo_modes: HashMap<TransactionId, Mode>,
|
||||
|
@ -172,7 +176,10 @@ impl EditorState {
|
|||
}
|
||||
matches!(
|
||||
self.operator_stack.last(),
|
||||
Some(Operator::FindForward { .. }) | Some(Operator::FindBackward { .. })
|
||||
Some(Operator::FindForward { .. })
|
||||
| Some(Operator::FindBackward { .. })
|
||||
| Some(Operator::Mark)
|
||||
| Some(Operator::Jump { .. })
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -254,6 +261,9 @@ impl Operator {
|
|||
Operator::AddSurrounds { .. } => "ys",
|
||||
Operator::ChangeSurrounds { .. } => "cs",
|
||||
Operator::DeleteSurrounds => "ds",
|
||||
Operator::Mark => "m",
|
||||
Operator::Jump { line: true } => "'",
|
||||
Operator::Jump { line: false } => "`",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,6 +271,8 @@ impl Operator {
|
|||
match self {
|
||||
Operator::Object { .. } | Operator::ChangeSurrounds { target: None } => &["VimObject"],
|
||||
Operator::FindForward { .. }
|
||||
| Operator::Mark
|
||||
| Operator::Jump { .. }
|
||||
| Operator::FindBackward { .. }
|
||||
| Operator::Replace
|
||||
| Operator::AddSurrounds { target: Some(_) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue