Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small bug fix to use exclusive Visual caret shape from 'guicursor' #1012

Merged

Conversation

citizenmatt
Copy link
Member

This PR will use the caret shape specified by ve in the 'guicursor' option when Visual mode is active and the 'selection' option equals exclusive. If the ve element isn't specified in 'guicursor', the v element is used instead.

This PR will also now use the ve element for Select mode. Previously, we were using the i Insert mode cursor (Vim doesn't have a separate Select cursor). This felt like a reasonable change at the time for several reasons. Firstly, Select mode is more similar to a traditional editor selection where typing inserts the text, replacing the selection, so using the Insert mode caret was an intuitive indicator of this. Secondly, when used in refactorings, the caret would be positioned after the selection, so a bar caret looks better.

However, the caret being positioned after the selection is because IdeaVim incorrectly treats Select mode as exclusive at all times, rather than based on the 'selection' option, like Visual. It is therefore more appropriate to use the ve cursor than the i cursor. Fortunately, the default for this is a bar caret, so there is little visual difference with this change. It is, however, more correct.

At some point, we need to fix Select's implementation and make it inclusive by default (VIM-3687). At this point, we will need to review the Select mode caret shape, as the bar will no longer be appropriate, but it will also be less intuitive for those coming from traditional editors.

@AlexPl292
Copy link
Member

Do I understand it right that there'll be no changes in the behaviour and caret shape in the case of the default options?

@citizenmatt
Copy link
Member Author

Mostly, yes, that's correct. There are no changes to behaviour. Select mode will still use the bar caret, but instead of it being hardcoded, it uses the ve segment from 'guicursor'. The default value for this is a bar.

The only change in caret shape is when in Visual mode, if 'selection' is set to exclusive, then we also use the ve segment here, which matches Vim behaviour. If the ve segment isn't defined (it is in defaults), then we fall back to v.

@AlexPl292
Copy link
Member

Great, thank you!

@AlexPl292 AlexPl292 merged commit 92ee271 into JetBrains:master Nov 5, 2024
4 checks passed
@citizenmatt citizenmatt deleted the bugfix/visual-exclusive-caret branch November 5, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants