Skip to content

Commit 18f14a6

Browse files
authored
vim: Fix paste action for visual modes (zed-industries#43031)
Closes zed-industries#41810 Release Notes: - Fixed paste not working correctly in vim visual modes
1 parent 58fe19d commit 18f14a6

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

crates/vim/src/normal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod convert;
33
mod delete;
44
mod increment;
55
pub(crate) mod mark;
6-
mod paste;
6+
pub(crate) mod paste;
77
pub(crate) mod repeat;
88
mod scroll;
99
pub(crate) mod search;

crates/vim/src/normal/paste.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{
1818
};
1919

2020
/// Pastes text from the specified register at the cursor position.
21-
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Action)]
21+
#[derive(Clone, Default, Deserialize, JsonSchema, PartialEq, Action)]
2222
#[action(namespace = vim)]
2323
#[serde(deny_unknown_fields)]
2424
pub struct Paste {

crates/vim/src/vim.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod state;
1919
mod surrounds;
2020
mod visual;
2121

22+
use crate::normal::paste::Paste as VimPaste;
2223
use collections::HashMap;
2324
use editor::{
2425
Anchor, Bias, Editor, EditorEvent, EditorSettings, HideMouseCursorOrigin, MultiBufferOffset,
@@ -922,6 +923,9 @@ impl Vim {
922923
cx,
923924
|vim, _: &editor::actions::Paste, window, cx| match vim.mode {
924925
Mode::Replace => vim.paste_replace(window, cx),
926+
Mode::Visual | Mode::VisualLine | Mode::VisualBlock => {
927+
vim.paste(&VimPaste::default(), window, cx);
928+
}
925929
_ => {
926930
vim.update_editor(cx, |_, editor, cx| editor.paste(&Paste, window, cx));
927931
}

0 commit comments

Comments
 (0)