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

Change editor.action.focusNextCursor to reveal the primary cursor instead of all cursors #182148

Merged
merged 3 commits into from
Mar 20, 2024

Conversation

akbyrd
Copy link
Contributor

@akbyrd akbyrd commented May 11, 2023

Closes #182147

Previously this command (and editor.action.focusPreviousCursor, introduced in #145909) called IViewModel.revealPrimaryCursor which in turn called CursorsController.revealPrimary. However, those names are deceptive. revealPrimary actually 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.focusNextCursor and focusPreviousCursor to 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:
Focus Next Cursor Fixed

After:
Focus Next Cursor Fixed

I audited the other uses of IViewModel.revealPrimaryCursor to 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

  • BaseMoveToCommand
  • TopCommand
  • BottomCommand
  • CancelSelection
  • RemoveSecondaryCursors

These each make sense to "reveal all". No single cursor has a strong priority over others

  • CursorMoveImpl
  • CursorMoveBasedCommand
  • HomeCommand
  • EndCommand
  • LineStartCommand
  • LineEndCommand
  • ExpandLineSelectionAction

These probably want to reveal the most recently added cursor, but that concept doesn't currently exist.

  • WordCommand
  • LineCommand

LineCommand doesn't work properly with multiple cursors anyway, so it's currently a bit moot.

akbyrd added 2 commits May 9, 2023 23:48
…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.
Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@alexdima alexdima enabled auto-merge (squash) March 20, 2024 13:31
@alexdima alexdima added this to the March 2024 milestone Mar 20, 2024
@alexdima alexdima merged commit 7f638be into microsoft:main Mar 20, 2024
6 checks passed
@akbyrd akbyrd deleted the fix-cursor-controller-reveal-primary branch March 20, 2024 16:56
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.

editor.action.focusNextCursor doesn't reveal the primary cursor
3 participants