Allow repeat in visual mode (#33569)

Release Notes:

- vim: Allow `.` in visual mode.
This commit is contained in:
Conrad Irwin 2025-06-30 14:04:28 -06:00 committed by GitHub
parent b0086b472f
commit a2e786e0f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 93 additions and 52 deletions

View file

@ -210,7 +210,8 @@
"ctrl-w space": "editor::OpenExcerptsSplit",
"ctrl-w g space": "editor::OpenExcerptsSplit",
"ctrl-6": "pane::AlternateFile",
"ctrl-^": "pane::AlternateFile"
"ctrl-^": "pane::AlternateFile",
".": "vim::Repeat"
}
},
{
@ -219,7 +220,6 @@
"ctrl-[": "editor::Cancel",
"escape": "editor::Cancel",
":": "command_palette::Toggle",
".": "vim::Repeat",
"c": "vim::PushChange",
"shift-c": "vim::ChangeToEndOfLine",
"d": "vim::PushDelete",

View file

@ -245,6 +245,7 @@ impl Vim {
}) else {
return;
};
if mode != Some(self.mode) {
if let Some(mode) = mode {
self.switch_mode(mode, false, window, cx)
}
@ -301,6 +302,7 @@ impl Vim {
}
RecordedSelection::None => {}
}
}
// insert internally uses repeat to handle counts
// vim doesn't treat 3a1 as though you literally repeated a1

View file

@ -2071,3 +2071,42 @@ async fn test_paragraph_multi_delete(cx: &mut gpui::TestAppContext) {
cx.simulate_shared_keystrokes("4 d a p").await;
cx.shared_state().await.assert_eq(indoc! {"ˇ"});
}
#[gpui::test]
async fn test_multi_cursor_replay(cx: &mut gpui::TestAppContext) {
let mut cx = VimTestContext::new(cx, true).await;
cx.set_state(
indoc! {
"
oˇne one one
two two two
"
},
Mode::Normal,
);
cx.simulate_keystrokes("3 g l s wow escape escape");
cx.assert_state(
indoc! {
"
woˇw wow wow
two two two
"
},
Mode::Normal,
);
cx.simulate_keystrokes("2 j 3 g l .");
cx.assert_state(
indoc! {
"
wow wow wow
woˇw woˇw woˇw
"
},
Mode::Normal,
);
}