Skip to content

Add completion.autoimport.insertQualifiedPath config option - #23349

Open
its-wasabi wants to merge 3 commits into
rust-lang:masterfrom
its-wasabi:insert-qualified-path-completion
Open

its-wasabi wants to merge 3 commits into
rust-lang:masterfrom
its-wasabi:insert-qualified-path-completion

Conversation

@its-wasabi

@its-wasabi its-wasabi commented Sep 12, 2026

Copy link
Copy Markdown

Adds an opt-in config flag that, when enabled, makes flyimport completions insert
the fully qualified path directly instead of the short name plus a use import.

The flag defaults to false, so there is no behavior change for existing users.

Addresses #13953.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 12, 2026
@rustbot

This comment has been minimized.

@its-wasabi
its-wasabi force-pushed the insert-qualified-path-completion branch from b97eb86 to 376771e Compare September 12, 2026 23:40
Adds an opt-in config flag that, when enabled, makes flyimport
completions insert the fully qualified path directly instead of
the short name plus a use import. Addresses rust-lang#13953.
@its-wasabi
its-wasabi force-pushed the insert-qualified-path-completion branch from 376771e to f2a02b1 Compare September 13, 2026 12:31
Comment thread crates/ide-completion/src/render.rs Outdated
{
import.import_path.display(db, completion.edition).to_smolstr()
} else {
name.clone()

@A4-Tacks A4-Tacks Sep 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's cleaner this way?

let (mut insert_text, mut item) = render_resolution_simple_(ctx, &local_name, import_to_add, resolution);

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Now render_resolution_simple_ takes name and returns (insert_text, item) to avoid repetitive display calls.

Comment thread crates/ide-completion/src/render.rs Outdated

@A4-Tacks A4-Tacks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM, but I'm not sure if it's suitable to add this feature

View changes since this review

Comment thread crates/ide-completion/src/render.rs Outdated
render_macro_pat(ctx, pattern_ctx, local_name, mac)
} else {
render_resolution_simple_(ctx, &local_name, import_to_add, resolution)
let name = local_name.display(ctx.db(), ctx.completion.edition).to_smolstr();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #23364, this can be completely moved into render_resolution_simple_

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, moved let name = ... into render_resolution_simple_ and created small return
struct to avoid tuple with ambiguous fields (name is further used in render_resolution_path).

Also I can rebase once #23364 merges, since it touches same lines but changes are independent.

@its-wasabi

Copy link
Copy Markdown
Author

Understood, please let me know if there's any concern beyond config surface.

It fills a real gap for users who prefer qualified paths over use (also requested in #13953).
Right now they have two choices:

  1. Accept the import and manually undo it, then write the path by hand. (tedious)
  2. Disable autoimport entirely, losing out-of-scope completions too, and still have to write paths by hand (reduced functionality)

It's opt-in, a light change, and defaults to false.

I did consider per-module/type setting for finer control, but kept it to a single bool to minimize config surface
(happy to discuss if that's a concern).

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

Personally I support this feature, but let's ask @rust-lang/rust-analyzer.

@flodiebold

Copy link
Copy Markdown
Member

IMO it does make sense to have a setting for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants