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.

Add counts to subsitute (and all)

Conrad Irwin16022e9c1a01
diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json
index eb2d7ecf410..d08b6ddff9b 100644
--- a/assets/keymaps/vim.json
+++ b/assets/keymaps/vim.json
@@ -131,7 +131,7 @@
}
},
{
- "context": "Editor && vim_mode == normal && vim_operator == none && !VimWaiting",
+ "context": "Editor && vim_mode == normal && (vim_operator == none || vim_operator == n) && !VimWaiting",
"bindings": {
"c": [
"vim::PushOperator",
diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs
index 19d000d3970..ecec2321043 100644
--- a/crates/vim/src/normal.rs
+++ b/crates/vim/src/normal.rs
@@ -484,7 +484,7 @@ pub fn substitute(vim: &mut Vim, count: usize, cx: &mut WindowContext) {
let selections = editor.selections.all::<Point>(cx);
for selection in selections.into_iter().rev() {
let end = if selection.start == selection.end {
- selection.start + Point::new(0, 1)
+ selection.start + Point::new(0, count as u32)
} else {
selection.end
};
diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs
index 293a4813e64..c7d944bd2a1 100644
--- a/crates/vim/src/test.rs
+++ b/crates/vim/src/test.rs
@@ -117,4 +117,8 @@ async fn test_substitute(cx: &mut gpui::TestAppContext) {
cx.set_state(indoc! {"a«bcˇ»deˇfg\n"}, Mode::Normal);
cx.simulate_keystrokes(["s", "x"]);
cx.assert_editor_state("axˇdexˇg\n");
+
+ cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal);
+ cx.simulate_keystrokes(["2", "s", "x"]);
+ cx.assert_editor_state("xˇc\n");
}