From 85aa458b9c49b8b9043f42b113944c5eb915035a Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sun, 14 Sep 2025 17:49:56 +0200 Subject: [PATCH] helix: Drop back to normal mode after yanking in select mode (#38133) Follow-up to https://github.com/zed-industries/zed/pull/38117. @romaninsh I'd appreciate if you could have a look :-) Release Notes: - N/A --- crates/vim/src/helix.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/vim/src/helix.rs b/crates/vim/src/helix.rs index 369ec2df11e2d5cf99a0b3d7a72ccd5619161f2f..cc235d67ae6efcae2fb5a5c5d899b9f7776cbda4 100644 --- a/crates/vim/src/helix.rs +++ b/crates/vim/src/helix.rs @@ -346,6 +346,9 @@ impl Vim { ); } }); + + // Drop back to normal mode after yanking + self.switch_mode(Mode::HelixNormal, true, window, cx); } fn helix_insert(&mut self, _: &HelixInsert, window: &mut Window, cx: &mut Context) { @@ -842,7 +845,16 @@ mod test { cx.simulate_keystrokes("y"); cx.shared_clipboard().assert_eq("worl"); cx.assert_state("hello «worlˇ»d", Mode::HelixNormal); + + // Test yanking in select mode character by character + cx.set_state("hello ˇworld", Mode::HelixNormal); + cx.simulate_keystroke("v"); + cx.assert_state("hello «wˇ»orld", Mode::HelixSelect); + cx.simulate_keystroke("y"); + cx.assert_state("hello «wˇ»orld", Mode::HelixNormal); + cx.shared_clipboard().assert_eq("w"); } + #[gpui::test] async fn test_shift_r_paste(cx: &mut gpui::TestAppContext) { let mut cx = VimTestContext::new(cx, true).await;