From ba41a8b6cb7af54fc6610ea14cf261dfcf7a05e8 Mon Sep 17 00:00:00 2001 From: liam Date: Tue, 26 May 2026 10:15:31 -0400 Subject: [PATCH] vim: Fix replace in helix select mode (#57553) Resolves https://github.com/zed-industries/zed/issues/57522 This diff fixes `r` in Helix select mode. The keybinding already pushed the replace operator in `helix_select`, but when the replacement character was typed, the operator dispatch only handled `HelixNormal`, so selected text in `HelixSelect` fell through and cleared the operator without editing the buffer. With this change, Helix select mode uses the same `helix_replace` path as Helix normal mode. Multi-character selections now replace each selected grapheme with the typed character and return to Helix normal mode, matching the existing behaviour for Helix normal selections. Release Notes: - Fixed `r` not replacing multi-character selections in Helix select mode. --- crates/vim/src/helix.rs | 6 ++++++ crates/vim/src/vim.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/vim/src/helix.rs b/crates/vim/src/helix.rs index ad5cd37e3f..b1ce35431c 100644 --- a/crates/vim/src/helix.rs +++ b/crates/vim/src/helix.rs @@ -2482,6 +2482,12 @@ mod test { cx.simulate_keystrokes("r x"); cx.assert_state("«xxˇ»", Mode::HelixNormal); + + cx.set_state("«aaˇ»", Mode::HelixSelect); + + cx.simulate_keystrokes("r x"); + + cx.assert_state("«xxˇ»", Mode::HelixNormal); } #[gpui::test] diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 678b30d8ad..e956e58568 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -2066,7 +2066,7 @@ impl Vim { Mode::Visual | Mode::VisualLine | Mode::VisualBlock => { self.visual_replace(text, window, cx) } - Mode::HelixNormal => self.helix_replace(&text, window, cx), + Mode::HelixNormal | Mode::HelixSelect => self.helix_replace(&text, window, cx), _ => self.clear_operator(window, cx), }, Some(Operator::Digraph { first_char }) => {