Skip to content

Commit 7447db8

Browse files
committed
Better completion test sorting
1 parent 4331688 commit 7447db8

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

crates/ide-completion/src/render.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ mod tests {
733733
) {
734734
let mut actual = get_all_items(TEST_CONFIG, ra_fixture, None);
735735
actual.retain(|it| kinds.contains(&it.kind));
736-
actual.sort_by_key(|it| cmp::Reverse(it.relevance.score()));
736+
actual.sort_by_key(|it| (cmp::Reverse(it.relevance.score()), it.label.primary.clone()));
737737
check_relevance_(actual, expect);
738738
}
739739

@@ -743,7 +743,7 @@ mod tests {
743743
actual.retain(|it| it.kind != CompletionItemKind::Snippet);
744744
actual.retain(|it| it.kind != CompletionItemKind::Keyword);
745745
actual.retain(|it| it.kind != CompletionItemKind::BuiltinType);
746-
actual.sort_by_key(|it| cmp::Reverse(it.relevance.score()));
746+
actual.sort_by_key(|it| (cmp::Reverse(it.relevance.score()), it.label.primary.clone()));
747747
check_relevance_(actual, expect);
748748
}
749749

@@ -824,9 +824,9 @@ fn main() {
824824
st dep::test_mod_b::Struct {…} dep::test_mod_b::Struct { } [type_could_unify]
825825
ex dep::test_mod_b::Struct { } [type_could_unify]
826826
st Struct Struct [type_could_unify+requires_import]
827+
md dep []
827828
fn main() fn() []
828829
fn test(…) fn(Struct) []
829-
md dep []
830830
st Struct Struct [requires_import]
831831
"#]],
832832
);
@@ -862,9 +862,9 @@ fn main() {
862862
"#,
863863
expect![[r#"
864864
un Union Union [type_could_unify+requires_import]
865+
md dep []
865866
fn main() fn() []
866867
fn test(…) fn(Union) []
867-
md dep []
868868
en Union Union [requires_import]
869869
"#]],
870870
);
@@ -900,9 +900,9 @@ fn main() {
900900
ev dep::test_mod_b::Enum::variant dep::test_mod_b::Enum::variant [type_could_unify]
901901
ex dep::test_mod_b::Enum::variant [type_could_unify]
902902
en Enum Enum [type_could_unify+requires_import]
903+
md dep []
903904
fn main() fn() []
904905
fn test(…) fn(Enum) []
905-
md dep []
906906
en Enum Enum [requires_import]
907907
"#]],
908908
);
@@ -937,9 +937,9 @@ fn main() {
937937
expect![[r#"
938938
ev dep::test_mod_b::Enum::Variant dep::test_mod_b::Enum::Variant [type_could_unify]
939939
ex dep::test_mod_b::Enum::Variant [type_could_unify]
940+
md dep []
940941
fn main() fn() []
941942
fn test(…) fn(Enum) []
942-
md dep []
943943
"#]],
944944
);
945945
}
@@ -967,9 +967,9 @@ fn main() {
967967
}
968968
"#,
969969
expect![[r#"
970+
md dep []
970971
fn main() fn() []
971972
fn test(…) fn(fn(usize) -> i32) []
972-
md dep []
973973
fn function fn(usize) -> i32 [requires_import]
974974
fn function(…) fn(isize) -> i32 [requires_import]
975975
"#]],
@@ -1000,9 +1000,9 @@ fn main() {
10001000
"#,
10011001
expect![[r#"
10021002
ct CONST i32 [type_could_unify+requires_import]
1003+
md dep []
10031004
fn main() fn() []
10041005
fn test(…) fn(i32) []
1005-
md dep []
10061006
ct CONST i64 [requires_import]
10071007
"#]],
10081008
);
@@ -1032,9 +1032,9 @@ fn main() {
10321032
"#,
10331033
expect![[r#"
10341034
sc STATIC i32 [type_could_unify+requires_import]
1035+
md dep []
10351036
fn main() fn() []
10361037
fn test(…) fn(i32) []
1037-
md dep []
10381038
sc STATIC i64 [requires_import]
10391039
"#]],
10401040
);
@@ -1090,8 +1090,8 @@ fn func(input: Struct) { }
10901090
10911091
"#,
10921092
expect![[r#"
1093-
st Struct Struct [type]
10941093
st Self Self [type]
1094+
st Struct Struct [type]
10951095
sp Self Struct [type]
10961096
st Struct Struct [type]
10971097
ex Struct [type]
@@ -1119,9 +1119,9 @@ fn main() {
11191119
"#,
11201120
expect![[r#"
11211121
lc input bool [type+name+local]
1122+
ex false [type]
11221123
ex input [type]
11231124
ex true [type]
1124-
ex false [type]
11251125
lc inputbad i32 [local]
11261126
fn main() fn() []
11271127
fn test(…) fn(bool) []
@@ -2088,9 +2088,9 @@ fn f() { A { bar: b$0 }; }
20882088
"#,
20892089
expect![[r#"
20902090
fn bar() fn() -> u8 [type+name]
2091+
ex bar() [type]
20912092
fn baz() fn() -> u8 [type]
20922093
ex baz() [type]
2093-
ex bar() [type]
20942094
st A A []
20952095
fn f() fn() []
20962096
"#]],
@@ -2199,8 +2199,8 @@ fn main() {
21992199
lc s S [type+name+local]
22002200
st S S [type]
22012201
st S S [type]
2202-
ex s [type]
22032202
ex S [type]
2203+
ex s [type]
22042204
fn foo(…) fn(&mut S) []
22052205
fn main() fn() []
22062206
"#]],
@@ -2218,8 +2218,8 @@ fn main() {
22182218
st S S [type]
22192219
lc ssss S [type+local]
22202220
st S S [type]
2221-
ex ssss [type]
22222221
ex S [type]
2222+
ex ssss [type]
22232223
fn foo(…) fn(&mut S) []
22242224
fn main() fn() []
22252225
"#]],
@@ -2252,11 +2252,11 @@ fn main() {
22522252
ex Foo [type]
22532253
lc foo &Foo [local]
22542254
lc *foo [type+local]
2255-
fn bar(…) fn(Foo) []
2256-
fn main() fn() []
2257-
md core []
22582255
tt Clone []
22592256
tt Copy []
2257+
fn bar(…) fn(Foo) []
2258+
md core []
2259+
fn main() fn() []
22602260
"#]],
22612261
);
22622262
}
@@ -2297,9 +2297,9 @@ fn main() {
22972297
st &S [type]
22982298
st T T []
22992299
st &T [type]
2300+
md core []
23002301
fn foo(…) fn(&S) []
23012302
fn main() fn() []
2302-
md core []
23032303
"#]],
23042304
)
23052305
}
@@ -2346,9 +2346,9 @@ fn main() {
23462346
st &mut S [type]
23472347
st T T []
23482348
st &mut T [type]
2349+
md core []
23492350
fn foo(…) fn(&mut S) []
23502351
fn main() fn() []
2351-
md core []
23522352
"#]],
23532353
)
23542354
}
@@ -2364,8 +2364,8 @@ fn foo(bar: u32) {
23642364
}
23652365
"#,
23662366
expect![[r#"
2367-
lc baz i32 [local]
23682367
lc bar u32 [local]
2368+
lc baz i32 [local]
23692369
fn foo(…) fn(u32) []
23702370
"#]],
23712371
);
@@ -2449,9 +2449,9 @@ fn main() {
24492449
st &T [type]
24502450
fn bar() fn() -> T []
24512451
fn &bar() [type]
2452+
md core []
24522453
fn foo(…) fn(&S) []
24532454
fn main() fn() []
2454-
md core []
24552455
"#]],
24562456
)
24572457
}
@@ -2702,8 +2702,8 @@ fn test() {
27022702
fn fn_builder() fn() -> FooBuilder [type_could_unify]
27032703
fn fn_ctr_wrapped() fn() -> Option<Foo<T>> [type_could_unify]
27042704
fn fn_ctr_wrapped_2() fn() -> Result<Foo<T>, u32> [type_could_unify]
2705-
me fn_returns_unit(…) fn(&self) [type_could_unify]
27062705
fn fn_other() fn() -> Option<u32> [type_could_unify]
2706+
me fn_returns_unit(…) fn(&self) [type_could_unify]
27072707
"#]],
27082708
);
27092709
}
@@ -2965,12 +2965,12 @@ fn foo() {
29652965
ev Foo::B Foo::B [type_could_unify]
29662966
ev Foo::A(…) Foo::A(T) [type_could_unify]
29672967
lc foo Foo<u32> [type+local]
2968-
ex foo [type]
29692968
ex Foo::B [type]
2969+
ex foo [type]
29702970
en Foo Foo<{unknown}> [type_could_unify]
2971-
fn foo() fn() []
29722971
fn bar() fn() -> Foo<u8> []
29732972
fn baz() fn() -> Foo<T> []
2973+
fn foo() fn() []
29742974
"#]],
29752975
);
29762976
}
@@ -3000,19 +3000,19 @@ fn main() {
30003000
expect![[r#"
30013001
sn not !expr [snippet]
30023002
me not() fn(self) -> <Self as Not>::Output [type_could_unify+requires_import]
3003-
sn ref &expr []
3004-
sn refm &mut expr []
3005-
sn deref *expr []
30063003
sn box Box::new(expr) []
3004+
sn call function(expr) []
3005+
sn const const {} []
30073006
sn dbg dbg!(expr) []
30083007
sn dbgr dbg!(&expr) []
3009-
sn call function(expr) []
3010-
sn match match expr {} []
3008+
sn deref *expr []
30113009
sn if if expr {} []
3012-
sn while while expr {} []
3013-
sn unsafe unsafe {} []
3014-
sn const const {} []
3010+
sn match match expr {} []
3011+
sn ref &expr []
3012+
sn refm &mut expr []
30153013
sn return return expr []
3014+
sn unsafe unsafe {} []
3015+
sn while while expr {} []
30163016
"#]],
30173017
);
30183018
}
@@ -3033,19 +3033,19 @@ fn main() {
30333033
&[CompletionItemKind::Snippet, CompletionItemKind::SymbolKind(SymbolKind::Method)],
30343034
expect![[r#"
30353035
me f() fn(&self) []
3036-
sn ref &expr []
3037-
sn refm &mut expr []
3038-
sn deref *expr []
30393036
sn box Box::new(expr) []
3037+
sn call function(expr) []
3038+
sn const const {} []
30403039
sn dbg dbg!(expr) []
30413040
sn dbgr dbg!(&expr) []
3042-
sn call function(expr) []
3041+
sn deref *expr []
30433042
sn let let []
30443043
sn letm let mut []
30453044
sn match match expr {} []
3046-
sn unsafe unsafe {} []
3047-
sn const const {} []
3045+
sn ref &expr []
3046+
sn refm &mut expr []
30483047
sn return return expr []
3048+
sn unsafe unsafe {} []
30493049
"#]],
30503050
);
30513051
}

0 commit comments

Comments
 (0)