rust-lang / rust-lang/rust-analyzer

Assists do not scale to multiple cursors

Open
#11,476 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lsp C-feature S-unactionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

In VS Code, when I place several cursors on distinct locations that trigger the same set of assists, then picking one of the listed assists results in RA applying the selected assist merely to the first cursor location. I expected RA to apply the assist individually per cursor position (unless they overlap (?) and excluding other pathological cases).

Examples

Let <|> denote a cursor. To reproduce in VS Code, press Ctrl+. (Quick Fix) and select one of the assists.

fn main() {
    // assist: Invert if
    <|>if true {} else {}
    <|>if true {} else {}
    <|>if false {} else {}
}

Outcome:

fn main() {
    <|>if false {} else {}
    <|>if true {} else {}
    <|>if false {} else {}
}

fn main() {
    // assist: Convert integer base
    <|>413;
    <|>10_344;
    <|>900;
}

Outcome:

fn main() {
    <|>0b110011101;
    <|>10_344;
    <|>900;
}

I searched thoroughly through the issue tracker (keywords cursor, multiple, assist) but could not find anything related.

rust-analyzer version: 7a17fb9c4 2022-02-13 nightly

rustc version: rustc 1.60.0-nightly (5d8767cb2 2022-02-12)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in VS Code with Ctrl+. using the multi-cursor Rust examples in the report. Trace how rust-analyzer applies a selected assist to cursor locations; done means the assist is applied independently at each applicable cursor without changing unrelated locations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.