-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
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/Downshortcuts - 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
Altand left clicking somewhere editor.action.addSelectionToNextFindMatcheditor.action.selectHighlightseditor.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.