rust-lang / rust-lang/rust-analyzer

rust-analyzer breaks tab completion on VSCode

Open
#14,400 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-completion C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust-analyzer version: 0.3.1443-standalone

rustc version: rustc 1.67.1 (d5a82bbd2 2023-02-07)

relevant settings:
"rust-analyzer.completion.autoimport.enable": false,
"rust-analyzer.completion.callable.snippets": "none",
"rust-analyzer.completion.autoself.enable": false

I use intellisense's tab completion, which allows me to cycle through completions by pressing tab until the proper completion shows up, at which point I can continue typing. This prevents the editor from erroneously substituting completions when I've finished with a line and want to move on to the next. It essentially makes it so that I can trust that the enter key will always insert a newline so that I can type without worrying whether or not the enter key will do the thing that my brain expects it to do.

Completions offered by rust-analyzer break tab completion.
In one case, I press tab, the first completion is substituted (with parenthesis or brackets that I didn't ask for and can't disable) and subsequent presses of the tab key only insert spaces according to my indentation setting.
In the other case, I press tab, the first completion is substituted (without those pesky auto-parenthesis/brackets), and subsequent presses of the tab key do nothing as VSCode fights to keep the cursor in place until I continue typing and rust-analyzer destroys the suggestions queue.

This has effectively disabled the use of completions in my rust workflow, and now a language I was really excited to learn is an absolute pain to do anything in.

MWE:

  • cargo new hello
  • open hello/src/main.rs in VSCode
  • set "editor.tabCompletion": "on" in settings.json
  • type prin and press tab twice, as if you were trying to get to println!
  • watch helplessly as you end up with print!( )
  • type a variable name that is the same as the beginning of another i.e. bean vs. bean_can
  • watch helplessly as bean never turns into bean_can no matter how many times you press tab
    • Note: this also pollutes the undo history!

Please let me know if there's anything else I can provide.

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

Reproduce the issue in cargo new hello using hello/src/main.rs, editor.tabCompletion set to on, and the listed rust-analyzer completion settings. Start by tracing how rust-analyzer completions interact with VSCode IntelliSense tab completion for prin and bean; done means repeated Tab presses cycle through suggestions without inserting unwanted text, spaces, or undo-history pollution.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, vscode
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.