Change editor.action.focusNextCursor to reveal the primary cursor instead of all cursors#182148
Merged
alexdima merged 3 commits intomicrosoft:mainfrom Mar 20, 2024
Merged
Conversation
…into "reveal all" and "reveal primary" variants - The original name was a lie. It wasn't revealing the primary cursor, it was revealing all cursors. - Some things actually want to reveal the primary cursor specifically, such as editor.action.focusNextCursor. If the set of cursors do not all fit in the view and the primary cursor is not currently visible the primary cursor should be revealed. - Other things want to reveal all cursors, such as cursorMove. However, there's likely room for improvement here as well: if the set of cursors do not all fit in the view and none of them are visible the closest cursor should probably be revealed. - All existing locations have been updated to use "reveal all" which maintains the exact same behavior as before. Locations that want to use the primary variant will be updated in a separate commit.
…l the primary cursor
alexr00
approved these changes
Mar 20, 2024
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes #182147
Previously this command (and
editor.action.focusPreviousCursor, introduced in #145909) calledIViewModel.revealPrimaryCursorwhich in turn calledCursorsController.revealPrimary. However, those names are deceptive.revealPrimaryactually reveals all cursors. There are cases where revealing the primary cursor and not all cursors is desirable, such as commands dedicated to changing the primary cursor.To support this I've renamed the existing "reveal primary" functions to "reveal all" and added a proper "reveal primary". I then updated
editor.action.focusNextCursorandfocusPreviousCursorto use the new "reveal primary" function.All other commands that used "reveal primary" now use "reveal all" which is just a rename and they have the same behavior they had before.
Before:

After:

I audited the other uses of
IViewModel.revealPrimaryCursorto determine if they want to reveal all cursors or the primary cursor.These all remove secondary cursors, resulting in a single cursor so it doesn't matter what they use
BaseMoveToCommandTopCommandBottomCommandCancelSelectionRemoveSecondaryCursorsThese each make sense to "reveal all". No single cursor has a strong priority over others
CursorMoveImplCursorMoveBasedCommandHomeCommandEndCommandLineStartCommandLineEndCommandExpandLineSelectionActionThese probably want to reveal the most recently added cursor, but that concept doesn't currently exist.
WordCommandLineCommandLineCommanddoesn't work properly with multiple cursors anyway, so it's currently a bit moot.