Implement Indent & Outdent as operators (#12430)
Release Notes: - Fixes [#9697](https://github.com/zed-industries/zed/issues/9697). Implements `>` and `<` with motions and text objects. Works with repeat action `.`
This commit is contained in:
parent
25050e8027
commit
8a659b0c60
7 changed files with 150 additions and 3 deletions
|
@ -304,6 +304,14 @@ impl KeyBindingContextPredicate {
|
|||
source,
|
||||
))
|
||||
}
|
||||
_ if is_vim_operator_char(next) => {
|
||||
let (operator, rest) = source.split_at(1);
|
||||
source = skip_whitespace(rest);
|
||||
Ok((
|
||||
KeyBindingContextPredicate::Identifier(operator.to_string().into()),
|
||||
source,
|
||||
))
|
||||
}
|
||||
_ => Err(anyhow!("unexpected character {next:?}")),
|
||||
}
|
||||
}
|
||||
|
@ -347,6 +355,10 @@ fn is_identifier_char(c: char) -> bool {
|
|||
c.is_alphanumeric() || c == '_' || c == '-'
|
||||
}
|
||||
|
||||
fn is_vim_operator_char(c: char) -> bool {
|
||||
c == '>' || c == '<'
|
||||
}
|
||||
|
||||
fn skip_whitespace(source: &str) -> &str {
|
||||
let len = source
|
||||
.find(|c: char| !c.is_whitespace())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue