Skip to content

Commit 052e722

Browse files
Merge #6946
6946: Better fuzzy heuristics r=matklad a=SomeoneToIgnore Continuation of the #6922, mainly created for a test. Turns out our current completions tests were sorting the completions by label, I had to remove that to test the order properly and update this order in a bunch of tests (ergo the changes) Co-authored-by: Kirill Bulatov <[email protected]>
2 parents 8b73135 + b45ec84 commit 052e722

File tree

12 files changed

+263
-216
lines changed

12 files changed

+263
-216
lines changed

crates/completion/src/completions/attribute.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ struct Test {}
428428
at Hash
429429
at PartialEq
430430
at PartialEq, Eq
431-
at PartialEq, Eq, PartialOrd, Ord
432431
at PartialEq, PartialOrd
432+
at PartialEq, Eq, PartialOrd, Ord
433433
"#]],
434434
);
435435
}
@@ -457,10 +457,10 @@ struct Test {}
457457
at Clone, Copy
458458
at Debug
459459
at Default
460-
at Eq
461-
at Eq, PartialOrd, Ord
462460
at Hash
461+
at Eq
463462
at PartialOrd
463+
at Eq, PartialOrd, Ord
464464
"#]],
465465
)
466466
}
@@ -472,14 +472,14 @@ struct Test {}
472472
expect![[r#"
473473
at allow(…)
474474
at automatically_derived
475-
at cfg(…)
476475
at cfg_attr(…)
476+
at cfg(…)
477477
at cold
478478
at deny(…)
479479
at deprecated = "…"
480480
at derive(…)
481-
at doc = "…"
482481
at export_name = "…"
482+
at doc = "…"
483483
at forbid(…)
484484
at ignore = "…"
485485
at inline(…)
@@ -518,15 +518,15 @@ struct Test {}
518518
expect![[r#"
519519
at allow(…)
520520
at automatically_derived
521-
at cfg(…)
522521
at cfg_attr(…)
522+
at cfg(…)
523523
at cold
524524
at crate_name = ""
525525
at deny(…)
526526
at deprecated = "…"
527527
at derive(…)
528-
at doc = "…"
529528
at export_name = "…"
529+
at doc = "…"
530530
at feature(…)
531531
at forbid(…)
532532
at global_allocator
@@ -538,8 +538,8 @@ struct Test {}
538538
at macro_export
539539
at macro_use
540540
at must_use = "…"
541-
at no_implicit_prelude
542541
at no_link
542+
at no_implicit_prelude
543543
at no_main
544544
at no_mangle
545545
at no_std

crates/completion/src/completions/dot.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ impl S {
8282
fn foo(s: S) { s.<|> }
8383
"#,
8484
expect![[r#"
85-
me bar() fn bar(&self)
8685
fd foo u32
86+
me bar() fn bar(&self)
8787
"#]],
8888
);
8989
}
@@ -98,8 +98,8 @@ impl S {
9898
}
9999
"#,
100100
expect![[r#"
101-
me foo() fn foo(self)
102101
fd the_field (u32,)
102+
me foo() fn foo(self)
103103
"#]],
104104
)
105105
}
@@ -114,8 +114,8 @@ impl A {
114114
}
115115
"#,
116116
expect![[r#"
117-
me foo() fn foo(&self)
118117
fd the_field (u32, i32)
118+
me foo() fn foo(&self)
119119
"#]],
120120
)
121121
}
@@ -147,8 +147,8 @@ mod inner {
147147
fn foo(a: inner::A) { a.<|> }
148148
"#,
149149
expect![[r#"
150-
fd crate_field u32
151150
fd pub_field u32
151+
fd crate_field u32
152152
fd super_field u32
153153
"#]],
154154
);

crates/completion/src/completions/keyword.rs

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,21 @@ mod tests {
223223
check(
224224
r"m<|>",
225225
expect![[r#"
226-
kw const
227-
kw enum
228-
kw extern
229226
kw fn
227+
kw use
230228
kw impl
231-
kw mod
232-
kw pub
233-
kw pub(crate)
234-
kw static
235-
kw struct
236229
kw trait
237-
kw type
230+
kw enum
231+
kw struct
238232
kw union
233+
kw mod
234+
kw const
235+
kw type
236+
kw static
237+
kw extern
239238
kw unsafe
240-
kw use
239+
kw pub(crate)
240+
kw pub
241241
"#]],
242242
);
243243
}
@@ -247,23 +247,23 @@ mod tests {
247247
check(
248248
r"fn quux() { <|> }",
249249
expect![[r#"
250-
kw const
251-
kw extern
252250
kw fn
251+
kw use
252+
kw impl
253+
kw trait
254+
kw match
255+
kw while
256+
kw loop
253257
kw if
254258
kw if let
255-
kw impl
256259
kw let
257-
kw loop
258-
kw match
259260
kw mod
260-
kw return
261-
kw static
262-
kw trait
261+
kw const
263262
kw type
263+
kw static
264+
kw extern
264265
kw unsafe
265-
kw use
266-
kw while
266+
kw return
267267
"#]],
268268
);
269269
}
@@ -273,23 +273,23 @@ mod tests {
273273
check(
274274
r"fn quux() { if true { <|> } }",
275275
expect![[r#"
276-
kw const
277-
kw extern
278276
kw fn
277+
kw use
278+
kw impl
279+
kw trait
280+
kw match
281+
kw while
282+
kw loop
279283
kw if
280284
kw if let
281-
kw impl
282285
kw let
283-
kw loop
284-
kw match
285286
kw mod
286-
kw return
287-
kw static
288-
kw trait
287+
kw const
289288
kw type
289+
kw static
290+
kw extern
290291
kw unsafe
291-
kw use
292-
kw while
292+
kw return
293293
"#]],
294294
);
295295
}
@@ -299,25 +299,25 @@ mod tests {
299299
check(
300300
r#"fn quux() { if true { () } <|> }"#,
301301
expect![[r#"
302-
kw const
303-
kw else
304-
kw else if
305-
kw extern
306302
kw fn
303+
kw use
304+
kw impl
305+
kw trait
306+
kw match
307+
kw while
308+
kw loop
307309
kw if
308310
kw if let
309-
kw impl
310311
kw let
311-
kw loop
312-
kw match
312+
kw else
313+
kw else if
313314
kw mod
314-
kw return
315-
kw static
316-
kw trait
315+
kw const
317316
kw type
317+
kw static
318+
kw extern
318319
kw unsafe
319-
kw use
320-
kw while
320+
kw return
321321
"#]],
322322
);
323323
check_edit(
@@ -336,13 +336,13 @@ fn quux() -> i32 {
336336
}
337337
"#,
338338
expect![[r#"
339+
kw match
340+
kw while
341+
kw loop
339342
kw if
340343
kw if let
341-
kw loop
342-
kw match
343-
kw return
344344
kw unsafe
345-
kw while
345+
kw return
346346
"#]],
347347
);
348348
}
@@ -352,8 +352,8 @@ fn quux() -> i32 {
352352
check(
353353
r"trait My { <|> }",
354354
expect![[r#"
355-
kw const
356355
kw fn
356+
kw const
357357
kw type
358358
kw unsafe
359359
"#]],
@@ -365,12 +365,12 @@ fn quux() -> i32 {
365365
check(
366366
r"impl My { <|> }",
367367
expect![[r#"
368-
kw const
369368
kw fn
370-
kw pub
371-
kw pub(crate)
369+
kw const
372370
kw type
373371
kw unsafe
372+
kw pub(crate)
373+
kw pub
374374
"#]],
375375
);
376376
}
@@ -380,25 +380,25 @@ fn quux() -> i32 {
380380
check(
381381
r"fn my() { loop { <|> } }",
382382
expect![[r#"
383-
kw break
384-
kw const
385-
kw continue
386-
kw extern
387383
kw fn
384+
kw use
385+
kw impl
386+
kw trait
387+
kw match
388+
kw while
389+
kw loop
388390
kw if
389391
kw if let
390-
kw impl
391392
kw let
392-
kw loop
393-
kw match
394393
kw mod
395-
kw return
396-
kw static
397-
kw trait
394+
kw const
398395
kw type
396+
kw static
397+
kw extern
399398
kw unsafe
400-
kw use
401-
kw while
399+
kw continue
400+
kw break
401+
kw return
402402
"#]],
403403
);
404404
}
@@ -409,8 +409,8 @@ fn quux() -> i32 {
409409
r"unsafe <|>",
410410
expect![[r#"
411411
kw fn
412-
kw impl
413412
kw trait
413+
kw impl
414414
"#]],
415415
);
416416
}
@@ -421,8 +421,8 @@ fn quux() -> i32 {
421421
r"fn my_fn() { unsafe <|> }",
422422
expect![[r#"
423423
kw fn
424-
kw impl
425424
kw trait
425+
kw impl
426426
"#]],
427427
);
428428
}
@@ -542,12 +542,12 @@ pub mod future {
542542
check(
543543
r#"fn main() { let _ = <|> }"#,
544544
expect![[r#"
545+
kw match
546+
kw while
547+
kw loop
545548
kw if
546549
kw if let
547-
kw loop
548-
kw match
549550
kw return
550-
kw while
551551
"#]],
552552
)
553553
}
@@ -562,8 +562,8 @@ struct Foo {
562562
}
563563
"#,
564564
expect![[r#"
565-
kw pub
566565
kw pub(crate)
566+
kw pub
567567
"#]],
568568
)
569569
}
@@ -600,12 +600,12 @@ fn foo() {
600600
}
601601
"#,
602602
expect![[r#"
603+
kw match
604+
kw while
605+
kw loop
603606
kw if
604607
kw if let
605-
kw loop
606-
kw match
607608
kw return
608-
kw while
609609
"#]],
610610
);
611611
}

0 commit comments

Comments
 (0)