Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for vim Operator::AddSurrounds.target in keymap config #23088

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/vim/src/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ impl Vim {
}
Some(Operator::AddSurrounds { target: None }) => {
waiting_operator = Some(Operator::AddSurrounds {
target: Some(SurroundsType::Object(object, around)),
target: Some(SurroundsType::Object {
target: object,
around,
}),
});
}
Some(Operator::ToggleComments) => self.toggle_comments_object(object, around, cx),
Expand Down
41 changes: 10 additions & 31 deletions crates/vim/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,46 +65,25 @@ pub enum Operator {
Delete,
Yank,
Replace,
Object {
around: bool,
},
FindForward {
before: bool,
},
FindBackward {
after: bool,
},
Sneak {
first_char: Option<char>,
},
SneakBackward {
first_char: Option<char>,
},
AddSurrounds {
#[serde(skip)]
target: Option<SurroundsType>,
},
ChangeSurrounds {
target: Option<Object>,
},
Object { around: bool },
FindForward { before: bool },
FindBackward { after: bool },
Sneak { first_char: Option<char> },
SneakBackward { first_char: Option<char> },
AddSurrounds { target: Option<SurroundsType> },
ChangeSurrounds { target: Option<Object> },
DeleteSurrounds,
Mark,
Jump {
line: bool,
},
Jump { line: bool },
Indent,
Outdent,
AutoIndent,
Rewrap,
Lowercase,
Uppercase,
OppositeCase,
Digraph {
first_char: Option<char>,
},
Literal {
prefix: Option<String>,
},
Digraph { first_char: Option<char> },
Literal { prefix: Option<String> },
Register,
RecordRegister,
ReplayRegister,
Expand Down
14 changes: 10 additions & 4 deletions crates/vim/src/surrounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ use crate::{
};
use editor::{movement, scroll::Autoscroll, Bias};
use language::BracketPair;
use schemars::JsonSchema;
use serde::Deserialize;

use std::sync::Arc;
use ui::ViewContext;

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Eq)]
pub enum SurroundsType {
#[serde(skip)]
Motion(Motion),
Object(Object, bool),
Object {
target: Object,
around: bool,
},
Selection,
}

Expand Down Expand Up @@ -49,8 +55,8 @@ impl Vim {

for selection in &display_selections {
let range = match &target {
SurroundsType::Object(object, around) => {
object.range(&display_map, selection.clone(), *around)
SurroundsType::Object { target, around } => {
target.range(&display_map, selection.clone(), *around)
}
SurroundsType::Motion(motion) => {
motion
Expand Down
Loading