rust-lang / rust-lang/rust-analyzer
Scrolling in VSCode resets `cursorColumnSelectUp/Down` context
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in VSCode with a Rust file loaded by rust-analyzer, testing mouse-wheel scrolling, Ctrl+Up/Down, and automatic scrolling with cursorColumnSelectUp/Down. Compare this with an unloaded Rust file and the other cursor commands; done means scrolling preserves the existing cursor-column selection context without changing the expected behavior of other cursor insertion actions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100