Skip to content

Commit

Permalink
only allow certain chars for change in
Browse files Browse the repository at this point in the history
  • Loading branch information
ayax79 committed Oct 11, 2024
1 parent 96e7f17 commit de85800
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/edit_mode/vi/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ where
if let Some('i') = input.peek() {
let _ = input.next();
match input.next() {
Some(c) => Some(Command::DeleteInside(*c)),
None => Some(Command::Incomplete),
Some(c) if is_valid_change_in(c) => Some(Command::DeleteInside(*c)),
_ => None,
}
} else {
Some(Command::Delete)
Expand Down Expand Up @@ -44,8 +44,8 @@ where
if let Some('i') = input.peek() {
let _ = input.next();
match input.next() {
Some(c) => Some(Command::ChangeInside(*c)),
None => Some(Command::Incomplete),
Some(c) if is_valid_change_in(c) => Some(Command::ChangeInside(*c)),
_ => None,
}
} else {
Some(Command::Change)
Expand Down Expand Up @@ -317,3 +317,10 @@ fn right_bracket_for(c: &char) -> char {
_ => *c,
}
}

fn is_valid_change_in(c: &char) -> bool {
match *c {
'(' | '[' | '{' | ')' | ']' | '}' | '"' | '\'' | '`' => true,
_ => false,
}
}

0 comments on commit de85800

Please sign in to comment.