Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide_completion/src/item.rs')
| -rw-r--r-- | crates/ide_completion/src/item.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/ide_completion/src/item.rs b/crates/ide_completion/src/item.rs index 41fae38da1..29b073cfa5 100644 --- a/crates/ide_completion/src/item.rs +++ b/crates/ide_completion/src/item.rs @@ -141,6 +141,8 @@ pub struct CompletionRelevance { pub is_item_from_trait: bool, /// This is set when an import is suggested whose name is already imported. pub is_name_already_imported: bool, + /// This is set for completions that will insert a `use` item. + pub requires_import: bool, /// Set for method completions of the `core::ops` and `core::cmp` family. pub is_op_method: bool, /// Set for item completions that are private but in the workspace. @@ -208,6 +210,7 @@ impl CompletionRelevance { is_local, is_item_from_trait, is_name_already_imported, + requires_import, is_op_method, is_private_editable, postfix_match, @@ -226,6 +229,10 @@ impl CompletionRelevance { if !is_name_already_imported { score += 1; } + // lower rank for items that don't need an import + if !requires_import { + score += 1; + } if exact_name_match { score += 10; } |