helix: Always offset cursor on selection#46311
Merged
SomeoneToIgnore merged 1 commit intozed-industries:mainfrom Mar 12, 2026
Merged
helix: Always offset cursor on selection#46311SomeoneToIgnore merged 1 commit intozed-industries:mainfrom
SomeoneToIgnore merged 1 commit intozed-industries:mainfrom
Conversation
0678444 to
34e770a
Compare
Contributor
|
Hey, thanks for working on this! The code was slightly refactored in #44284 yesterday, so you might want to change it to something like this: diff --git a/crates/vim/src/state.rs b/crates/vim/src/state.rs
index f4c3af7131..86de2b0896 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 860af285c4..2d8380aca5 100644
--- a/crates/vim/src/vim.rs
+++ b/crates/vim/src/vim.rs
@@ -2041,7 +2041,7 @@ impl Vim {
collapse_matches: !HelixModeSetting::get_global(cx).0,
input_enabled: self.editor_input_enabled(),
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),
}
|
34e770a to
d3edb88
Compare
jrobsonchase
added a commit
to jrobsonchase/zed
that referenced
this pull request
Jan 26, 2026
zed-industries#46311 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. Co-authored-by: Nils Koch <mail@nilskch.dev>
Contributor
Author
|
Cool, thanks for the heads-up and suggested resolution! I applied it and noted you as a co-author @nilskch |
d3edb88 to
7ad6b33
Compare
jrobsonchase
added a commit
to jrobsonchase/zed
that referenced
this pull request
Feb 18, 2026
zed-industries#46311 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. Co-authored-by: Nils Koch <mail@nilskch.dev>
7ad6b33 to
45a3039
Compare
kubkon
approved these changes
Mar 3, 2026
Member
|
@jrobsonchase would you mind rebasing/merging main please? |
45a3039 to
c757bd4
Compare
jrobsonchase
added a commit
to jrobsonchase/zed
that referenced
this pull request
Mar 3, 2026
zed-industries#46311 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. Co-authored-by: Nils Koch <mail@nilskch.dev>
zed-industries#46311 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. Co-authored-by: Nils Koch <mail@nilskch.dev>
c757bd4 to
e5833ee
Compare
Contributor
|
@kubkon CI needs approval here! |
tommyming
pushed a commit
to tommyming/zed
that referenced
this pull request
Mar 13, 2026
zed-industries#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 zed-industries#20121 Closes zed-industries#46998 Release Notes: - Fixed the cursor offset in non-visual helix selections Co-authored-by: Nils Koch <mail@nilskch.dev>
This was referenced Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#42837 added the
cursor_offset_on_selectionfield, 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_settingsmethod.I also considered simply moving
Mode::HelixNormalup to thetruearm of the match in theis_visualmethod 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: