Compare commits

...

1 Commits

Author SHA1 Message Date
Smit Barmase
4f1e1c8a7a fix paragraph yank 2025-06-10 11:24:06 +05:30
3 changed files with 36 additions and 1 deletions

View File

@@ -80,7 +80,12 @@ impl Vim {
start_positions.insert(selection.id, start_position);
});
});
vim.yank_selections_content(editor, MotionKind::Exclusive, window, cx);
let kind = if object == Object::Paragraph {
MotionKind::Linewise
} else {
MotionKind::Exclusive
};
vim.yank_selections_content(editor, kind, window, cx);
editor.change_selections(None, window, cx, |s| {
s.move_with(|_, selection| {
let (head, goal) = start_positions.remove(&selection.id).unwrap();

View File

@@ -1867,6 +1867,25 @@ mod test {
}
}
#[gpui::test]
async fn test_yank_paragraph_object(cx: &mut gpui::TestAppContext) {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state(indoc! {
"The quick brownˇ fox
jumps over the lazy dog.
"
})
.await;
cx.simulate_shared_keystrokes("y i p").await;
cx.shared_clipboard()
.await
.assert_eq("The quick brown fox\njumps over the lazy dog.\n");
cx.simulate_shared_keystrokes("y a p").await;
cx.shared_clipboard()
.await
.assert_eq("The quick brown fox\njumps over the lazy dog.\n\n");
}
// Test string with "`" for opening surrounders and "'" for closing surrounders
const SURROUNDING_MARKER_STRING: &str = indoc! {"
ˇTh'ˇe ˇ`ˇ'ˇquˇi`ˇck broˇ'wn`

View File

@@ -0,0 +1,11 @@
{"Put":{"state":"The quick brownˇ fox\njumps over the lazy dog.\n"}}
{"Key":"y"}
{"Key":"i"}
{"Key":"p"}
{"Get":{"state":"ˇThe quick brown fox\njumps over the lazy dog.\n","mode":"Normal"}}
{"ReadRegister":{"name":"\"","value":"The quick brown fox\njumps over the lazy dog.\n"}}
{"Key":"y"}
{"Key":"a"}
{"Key":"p"}
{"Get":{"state":"ˇThe quick brown fox\njumps over the lazy dog.\n","mode":"Normal"}}
{"ReadRegister":{"name":"\"","value":"The quick brown fox\njumps over the lazy dog.\n\n"}}