vim: Add (half of) ctrl-v/ctrl-q (#19585)

Release Notes:

- vim: Add `ctrl-v`/`ctrl-q` to type any unicode code point. For example
`ctrl-v escape` inserts an escape character(U+001B), or `ctrl-v u 1 0 E
2` types ტ (U+10E2). As in vim `ctrl-v ctrl-j` inserts U+0000 not
U+000A. Zed does not yet implement insertion of the vim-specific
representation of the typed keystroke for other keystrokes.
- vim: Add `ctrl-shift-v` as an alias for paste on Linux
This commit is contained in:
Conrad Irwin 2024-10-31 23:25:42 -06:00 committed by GitHub
parent f8ab86f930
commit 75f1862268
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 337 additions and 10 deletions

View file

@ -296,6 +296,7 @@ impl Vim {
object::register(editor, cx);
visual::register(editor, cx);
change_list::register(editor, cx);
digraph::register(editor, cx);
cx.defer(|vim, cx| {
vim.focused(false, cx);
@ -359,9 +360,15 @@ impl Vim {
}
if let Some(operator) = self.active_operator() {
if !operator.is_waiting(self.mode) {
self.clear_operator(cx);
self.stop_recording_immediately(Box::new(ClearOperators), cx)
match operator {
Operator::Literal { prefix } => {
self.handle_literal_keystroke(keystroke_event, prefix.unwrap_or_default(), cx);
}
_ if !operator.is_waiting(self.mode) => {
self.clear_operator(cx);
self.stop_recording_immediately(Box::new(ClearOperators), cx)
}
_ => {}
}
}
}
@ -602,14 +609,18 @@ impl Vim {
if let Some(active_operator) = active_operator {
if active_operator.is_waiting(self.mode) {
mode = "waiting".to_string();
if matches!(active_operator, Operator::Literal { .. }) {
mode = "literal".to_string();
} else {
mode = "waiting".to_string();
}
} else {
mode = "operator".to_string();
operator_id = active_operator.id();
mode = "operator".to_string();
}
}
if mode != "waiting" && mode != "insert" && mode != "replace" {
if mode == "normal" || mode == "visual" || mode == "operator" {
context.add("VimControl");
}
context.set("vim_mode", mode);
@ -998,6 +1009,9 @@ impl Vim {
self.push_operator(Operator::Digraph { first_char }, cx);
}
}
Some(Operator::Literal { prefix }) => {
self.handle_literal_input(prefix.unwrap_or_default(), &text, cx)
}
Some(Operator::AddSurrounds { target }) => match self.mode {
Mode::Normal => {
if let Some(target) = target {