vim: ctrl-r while we're on a register kick (#13085)

Release Notes:

- vim: Support `ctrl-r X` to paste in insert mode (#4308)
This commit is contained in:
Conrad Irwin 2024-06-14 22:38:38 -06:00 committed by GitHub
parent e6def62c23
commit fc19cc0ddf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 122 additions and 83 deletions

View file

@ -624,7 +624,7 @@ impl Vim {
editor: Option<&mut Editor>,
cx: &mut WindowContext,
) -> Option<Register> {
let Some(register) = register else {
let Some(register) = register.filter(|reg| *reg != '"') else {
let setting = VimSettings::get_global(cx).use_system_clipboard;
return match setting {
UseSystemClipboard::Always => cx.read_from_clipboard().map(|item| item.into()),
@ -882,8 +882,24 @@ impl Vim {
Some(Operator::Mark) => Vim::update(cx, |vim, cx| {
normal::mark::create_mark(vim, text, false, cx)
}),
Some(Operator::Register) => Vim::update(cx, |vim, cx| {
vim.select_register(text, cx);
Some(Operator::Register) => Vim::update(cx, |vim, cx| match vim.state().mode {
Mode::Insert => {
vim.update_active_editor(cx, |vim, editor, cx| {
if let Some(register) =
vim.read_register(text.chars().next(), Some(editor), cx)
{
editor.do_paste(
&register.text.to_string(),
register.clipboard_selections.clone(),
false,
cx,
)
}
});
}
_ => {
vim.select_register(text, cx);
}
}),
Some(Operator::Jump { line }) => normal::mark::jump(text, line, cx),
_ => match Vim::read(cx).state().mode {