rust-lang / rust-lang/rust-analyzer

selection-based editors miss lots of assists

Open
#17,539 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-assists A-third-party-client C-enhancement
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

See https://github.com/helix-editor/helix/issues/9631

I use RA together with Helix. The edition model of this editor is such that the selection is never empty. I'm not sure whether this is unique to Helix, maybe Kakoune works in a similar way.

As per the issue linked above, this means that there are many assists that don't appear in their "natural" place, say:

d[b]g!(some_expr);  // <-- selection of 1 character over "b"

does not offer "Remove dbg! macro", because of this check. The only possibility is selecting the whole dbg!(...) expression.

I'm not sure what the right way to tackle this would be. Maybe there could be a setting that the editor could toggle to indicate "I'm a selection-based editor", so that those assists can relax those checks. Maybe those checks ought to be relaxed in all cases (at least, for selections of length 1)? Maybe this is something the LSP standard should handle itself 🙈 ?

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 with the linked issue 9631 and the check in crates/ide-assists/src/handlers/remove_dbg.rs. Compare how selection-based editors such as Helix represent selections and determine whether the desired behavior belongs in rust-analyzer or the LSP standard; done requires an agreed approach for making assists appear at their natural location.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.