editor: Refactor cursor_offset_on_selection field in favor of VimModeSettings#44889
Merged
editor: Refactor cursor_offset_on_selection field in favor of VimModeSettings#44889
Conversation
In a previous Pull Request, a new field was added to `editor::Editor`, namely `cursor_offset_on_selection`, in order to control whether the cursor representing the head of a selection should be positioned in the last selected character, as we have on Vim mode, or after, like we have when Vim mode is disabled. This field would then be set by the `vim` crate, depending on the current vim mode. However, it was noted that `vim_mode_setting::VimModeSetting` already exsits and allows other crates to determine whether Vim mode is enabled or not. Since we're already checking `!range.is_empty()` in `editor::element::SelectionLayout::new` we can then rely on simply determining whether Vim mode is enabled to decide whether tho shift the cursor one position to the left when making a selection. As such, this commit removes the `cursor_offset_on_selection` field, as well as any related methods in favor of a new `Editor.vim_mode_enabled` method, which can be used to achieve the same behavior.
CherryWorm
pushed a commit
to CherryWorm/zed
that referenced
this pull request
Dec 16, 2025
…Settings (zed-industries#44889) In a previous Pull Request, a new field was added to `editor::Editor`, namely `cursor_offset_on_selection`, in order to control whether the cursor representing the head of a selection should be positioned in the last selected character, as we have on Vim mode, or after, like we have when Vim mode is disabled. This field would then be set by the `vim` crate, depending on the current vim mode. However, it was noted that `vim_mode_setting::VimModeSetting` already exsits and allows other crates to determine whether Vim mode is enabled or not. Since we're already checking `!range.is_empty()` in `editor::element::SelectionLayout::new` we can then rely on simply determining whether Vim mode is enabled to decide whether tho shift the cursor one position to the left when making a selection. As such, this commit removes the `cursor_offset_on_selection` field, as well as any related methods in favor of a new `Editor.vim_mode_enabled` method, which can be used to achieve the same behavior. Relates to zed-industries#42837 Release Notes: - N/A
CherryWorm
pushed a commit
to CherryWorm/zed
that referenced
this pull request
Dec 16, 2025
… VimModeSettings" (zed-industries#44960) Reverts zed-industries#44889 Release Notes: - N/A
jrobsonchase
added a commit
to jrobsonchase/zed
that referenced
this pull request
Jan 8, 2026
zed-industries#44889 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.
This was referenced Jan 8, 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.
In a previous Pull Request, a new field was added to
editor::Editor, namelycursor_offset_on_selection, in order to control whether the cursor representing the head of a selection should be positioned in the last selected character, as we have on Vim mode, or after, like we have when Vim mode is disabled.This field would then be set by the
vimcrate, depending on the current vim mode. However, it was noted thatvim_mode_setting::VimModeSettingalready exsits and allows other crates to determine whether Vim mode is enabled or not. Since we're already checking!range.is_empty()ineditor::element::SelectionLayout::newwe can then rely on simply determining whether Vim mode is enabled to decide whether tho shift the cursor one position to the left when making a selection.As such, this commit removes the
cursor_offset_on_selectionfield, as well as any related methods in favor of a newEditor.vim_mode_enabledmethod, which can be used to achieve the same behavior.Relates to #42837
Release Notes: