Skip to content

Remove underscore prefix from locals on compleitionΒ #19631

Open
@bbb651

Description

@bbb651

In this situation, after completing _foo

fn main() {
    let _foo = 0;
    _f|
}

The result is:

fn main() {
    let _foo = 0;
    _foo|
}

I expect the result to be:

fn main() {
    let foo = 0;
    foo|
}

Since by definition, after completion the variable is used, and saves the rename the user would have to do to avoid a warning.

I think this should be initially apply only to locals (including arguments), and possibly expanded to items which are comparatively rarer and have more unanswered questions (Should it only apply to items within the same scope? Which kind of items should it apply to? Should it only occur when visibility is pub(crate) or lower?).

Should the completion item itself appear as _foo or foo? I think the label should be foo but the filterText be _foo, that way it's clear the rename will take place, while making it still possible to find by typing _|. Would this make it appear too low when searching f|?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions