From 81da953acfdcba1951875abb9664cd371d4c7f86 Mon Sep 17 00:00:00 2001 From: Josh Robson Chase Date: Thu, 12 Mar 2026 05:07:58 -0400 Subject: [PATCH] helix: Always offset cursor on selection (#46311) https://github.com/zed-industries/zed/pull/42837 added the `cursor_offset_on_selection` field, which displays the cursor *after* the end of the selection unless a vim visual mode is enabled, in which case it gets displayed *at* the end of the selection. However, the real helix is effectively *always* in select mode, and will always display the cursor at the end of the selection, whether that selection is made via its visual mode, a movement key, or with the mouse. This makes it so that the helix mode setting is taken into account regardless of the visual-ness of the vim mode in the `sync_vim_settings` method. I also considered simply moving `Mode::HelixNormal` up to the `true` arm of the match in the `is_visual` method since helix is kinda *always* in visual mode, but I figured that could have some unintended consequences and chose to err on the side of caution. Possibly related to #20121 Closes #46998 Release Notes: - Fixed the cursor offset in non-visual helix selections Co-authored-by: Nils Koch --- crates/vim/src/state.rs | 4 ++++ crates/vim/src/vim.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/vim/src/state.rs b/crates/vim/src/state.rs index 69b2816cc0bdc5aeed2af787b9a92166e2c93956..4e71a698ff0789a462e5ec2e83d673421621c884 100644 --- a/crates/vim/src/state.rs +++ b/crates/vim/src/state.rs @@ -73,6 +73,10 @@ impl Mode { Self::Normal | Self::Insert | Self::Replace | Self::HelixNormal => false, } } + + pub fn is_helix(&self) -> bool { + matches!(self, Self::HelixNormal | Self::HelixSelect) + } } #[derive(Clone, Debug, PartialEq)] diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 8c551bcd2768043ae416157c80d4d2f9faa19092..3085dc5b3763222eb4b06d2ee551e026feba0002 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -2070,7 +2070,7 @@ impl Vim { input_enabled: self.editor_input_enabled(), expects_character_input: self.expects_character_input(), autoindent: self.should_autoindent(), - cursor_offset_on_selection: self.mode.is_visual(), + cursor_offset_on_selection: self.mode.is_visual() || self.mode.is_helix(), line_mode: matches!(self.mode, Mode::VisualLine), hide_edit_predictions: !matches!(self.mode, Mode::Insert | Mode::Replace), }