Skip to content

Scrolling in VSCode resets cursorColumnSelectUp/Down context #20939

@Possseidon

Description

@Possseidon

editor or extension: tested in VSCode Version 0.4.2661 and 0.4.2662

For some context: The VSCode built-in actions cursorColumnSelectUp and cursorColumnSelectDown add a new cursor above or below the current cursor. This command can be chained to both add additional cursors and also remove some again.

Issue

When editing a Rust file that is loaded as part of rust-analyzer's workspace, then any form of scrolling resets the context of how many cursors were already added. Executing cursorColumnSelectUp/Down after scrolling removes all extra cursors before adding the new cursor.

I've tested scrolling using 3 different methods, all of which cause the issue:

  • Scrolling via mouse wheel
  • Scrolling via Ctrl+Up/Down shortcuts
  • Automatic scrolling due to the added cursors reaching the bottom/top of the visible area

As you might imaging, the last one is especially annoying (and even makes it impossible to add more cursors than fit into the visible area since the reset causes it to scroll back to the initial cursor).

Notes

The issue only occurs if the file is properly loaded by rust-analyzer. Everything works fine when editing a *.rs file that is e.g. not part of the current crate, despite rust-analyzer having a workspace loaded.

There are other ways in which extra cursors can be added:

  • Holding Alt and left clicking somewhere
  • editor.action.addSelectionToNextFindMatch
  • editor.action.selectHighlights
  • editor.action.insertCursorAbove/Below

But all of these seem to work just fine. Note that adding cursors in any of these ways also resets the cursorColumnSelectUp/Down context, but that is expected behavior and has nothing to do with rust-analyzer.

Using editor.action.insertCursorAbove as a replacement is not optimal, since it works slightly differently: You cannot remove cursors by running the opposite command. It instead adds additional cursors on the opposite end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-vscodevscode plugin issuesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions