Skip to content

editor: Refactor cursor_offset_on_selection field in favor of VimModeSettings#44889

Merged
dinocosta merged 1 commit intomainfrom
42837-refactor
Dec 15, 2025
Merged

editor: Refactor cursor_offset_on_selection field in favor of VimModeSettings#44889
dinocosta merged 1 commit intomainfrom
42837-refactor

Conversation

@dinocosta
Copy link
Member

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 #42837

Release Notes:

  • N/A

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.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 15, 2025
@dinocosta dinocosta merged commit 0410b23 into main Dec 15, 2025
36 of 38 checks passed
@dinocosta dinocosta deleted the 42837-refactor branch December 15, 2025 19:18
benbrandt added a commit that referenced this pull request Dec 16, 2025
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
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant