vim: Support for q and @ (#13761)

Fixes: #1504

Release Notes:

- vim: Support for macros (`q` and `@`) to record and replay (#1506,
#4448)
This commit is contained in:
Conrad Irwin 2024-07-03 09:03:39 -06:00 committed by GitHub
parent dceb0827e8
commit 3348c3ab4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 491 additions and 316 deletions

View file

@ -1,5 +1,6 @@
use std::{fmt::Display, ops::Range, sync::Arc};
use crate::normal::repeat::Replayer;
use crate::surrounds::SurroundsType;
use crate::{motion::Motion, object::Object};
use collections::HashMap;
@ -68,6 +69,8 @@ pub enum Operator {
Uppercase,
OppositeCase,
Register,
RecordRegister,
ReplayRegister,
}
#[derive(Default, Clone)]
@ -155,15 +158,23 @@ impl From<String> for Register {
pub struct WorkspaceState {
pub last_find: Option<Motion>,
pub recording: bool,
pub dot_recording: bool,
pub dot_replaying: bool,
pub stop_recording_after_next_action: bool,
pub replaying: bool,
pub ignore_current_insertion: bool,
pub recorded_count: Option<usize>,
pub recorded_actions: Vec<ReplayableAction>,
pub recorded_selection: RecordedSelection,
pub recording_register: Option<char>,
pub last_recorded_register: Option<char>,
pub last_replayed_register: Option<char>,
pub replayer: Option<Replayer>,
pub last_yank: Option<SharedString>,
pub registers: HashMap<char, Register>,
pub recordings: HashMap<char, Vec<ReplayableAction>>,
}
#[derive(Debug)]
@ -228,6 +239,8 @@ impl EditorState {
| Some(Operator::FindBackward { .. })
| Some(Operator::Mark)
| Some(Operator::Register)
| Some(Operator::RecordRegister)
| Some(Operator::ReplayRegister)
| Some(Operator::Jump { .. })
)
}
@ -322,6 +335,8 @@ impl Operator {
Operator::Lowercase => "gu",
Operator::OppositeCase => "g~",
Operator::Register => "\"",
Operator::RecordRegister => "q",
Operator::ReplayRegister => "@",
}
}
@ -333,6 +348,8 @@ impl Operator {
| Operator::Jump { .. }
| Operator::FindBackward { .. }
| Operator::Register
| Operator::RecordRegister
| Operator::ReplayRegister
| Operator::Replace
| Operator::AddSurrounds { target: Some(_) }
| Operator::ChangeSurrounds { .. }