Skip to content

Commit 65839f4

Browse files
committed
add 'use' prefix for any auto-import
1 parent 9c98606 commit 65839f4

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

crates/ide_completion/src/completions/flyimport.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,9 @@ fn main() {
368368
}
369369
"#,
370370
expect![[r#"
371-
st dep::some_module::ThirdStruct
372-
st dep::some_module::AfterThirdStruct
373-
st dep::some_module::ThiiiiiirdStruct
371+
st ThirdStruct (use dep::some_module::ThirdStruct)
372+
st AfterThirdStruct (use dep::some_module::AfterThirdStruct)
373+
st ThiiiiiirdStruct (use dep::some_module::ThiiiiiirdStruct)
374374
"#]],
375375
);
376376
}
@@ -817,7 +817,7 @@ fn main() {
817817
check(
818818
fixture,
819819
expect![[r#"
820-
st foo::bar::baz::Item
820+
st Item (use foo::bar::baz::Item)
821821
"#]],
822822
);
823823

@@ -997,7 +997,7 @@ fn main() {
997997
TE$0
998998
}"#,
999999
expect![[r#"
1000-
ct foo::TEST_CONST
1000+
ct TEST_CONST (use foo::TEST_CONST)
10011001
"#]],
10021002
);
10031003

@@ -1014,7 +1014,7 @@ fn main() {
10141014
te$0
10151015
}"#,
10161016
expect![[r#"
1017-
ct foo::TEST_CONST
1017+
ct TEST_CONST (use foo::TEST_CONST)
10181018
fn test_function() (use foo::test_function) fn() -> i32
10191019
"#]],
10201020
);

crates/ide_completion/src/item.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,7 @@ impl Builder {
429429
{
430430
lookup = lookup.or_else(|| Some(label.clone()));
431431
insert_text = insert_text.or_else(|| Some(label.clone()));
432-
433-
let original_path_label = original_path.to_string();
434-
if original_path_label.ends_with(&label) {
435-
label = original_path_label;
436-
} else {
437-
format_to!(label, " (use {})", original_path)
438-
}
432+
format_to!(label, " (use {})", original_path)
439433
} else if let Some(trait_name) = self.trait_name {
440434
insert_text = insert_text.or_else(|| Some(label.clone()));
441435
format_to!(label, " (as {})", trait_name)

0 commit comments

Comments
 (0)