Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

vim: Fix paste action for visual modes (#43031)

Adrian18f14a6ebf62
diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs
index e53e2306d6f..aee0b424f04 100644
--- a/crates/vim/src/normal.rs
+++ b/crates/vim/src/normal.rs
@@ -3,7 +3,7 @@ mod convert;
mod delete;
mod increment;
pub(crate) mod mark;
-mod paste;
+pub(crate) mod paste;
pub(crate) mod repeat;
mod scroll;
pub(crate) mod search;
diff --git a/crates/vim/src/normal/paste.rs b/crates/vim/src/normal/paste.rs
index 77305ea783c..dffabde8fd8 100644
--- a/crates/vim/src/normal/paste.rs
+++ b/crates/vim/src/normal/paste.rs
@@ -18,7 +18,7 @@ use crate::{
};
/// Pastes text from the specified register at the cursor position.
-#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
+#[derive(Clone, Default, Deserialize, JsonSchema, PartialEq, Action)]
#[action(namespace = vim)]
#[serde(deny_unknown_fields)]
pub struct Paste {
diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs
index b633c9ef3c5..9f31b3d3ac0 100644
--- a/crates/vim/src/vim.rs
+++ b/crates/vim/src/vim.rs
@@ -19,6 +19,7 @@ mod state;
mod surrounds;
mod visual;
+use crate::normal::paste::Paste as VimPaste;
use collections::HashMap;
use editor::{
Anchor, Bias, Editor, EditorEvent, EditorSettings, HideMouseCursorOrigin, MultiBufferOffset,
@@ -922,6 +923,9 @@ impl Vim {
cx,
|vim, _: &editor::actions::Paste, window, cx| match vim.mode {
Mode::Replace => vim.paste_replace(window, cx),
+ Mode::Visual | Mode::VisualLine | Mode::VisualBlock => {
+ vim.paste(&VimPaste::default(), window, cx);
+ }
_ => {
vim.update_editor(cx, |_, editor, cx| editor.paste(&Paste, window, cx));
}