mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
complete: Sort --keep-order completions smaller
This should make the sort have a strict weak ordering, which rust requires since 1.81 (or it will panic). Note: This changes the order, but that's *fine* since the current order is random weirdness anyway. Fixes #10763
This commit is contained in:
parent
2238c07b91
commit
5e8adb18f4
3 changed files with 11 additions and 5 deletions
|
@ -480,6 +480,12 @@ fn natural_compare_completions(a: &Completion, b: &Completion) -> Ordering {
|
|||
// Both completions are from a source with the --keep-order flag.
|
||||
return Ordering::Equal;
|
||||
}
|
||||
if (a.flags).contains(CompleteFlags::DONT_SORT) {
|
||||
return Ordering::Less;
|
||||
}
|
||||
if (b.flags).contains(CompleteFlags::DONT_SORT) {
|
||||
return Ordering::Greater;
|
||||
}
|
||||
wcsfilecmp(&a.completion, &b.completion)
|
||||
}
|
||||
|
||||
|
|
|
@ -18,15 +18,15 @@ complete -c fooc -fa "kilo juliett lima"
|
|||
|
||||
# Generate completions
|
||||
complete -C"fooc "
|
||||
# CHECK: alpha
|
||||
# CHECK: bravo
|
||||
# CHECK: india
|
||||
# CHECK: foxtrot
|
||||
# CHECK: hotel
|
||||
# CHECK: golf
|
||||
# CHECK: charlie
|
||||
# CHECK: delta
|
||||
# CHECK: echo
|
||||
# CHECK: alpha
|
||||
# CHECK: bravo
|
||||
# CHECK: delta
|
||||
# CHECK: juliett
|
||||
# CHECK: kilo
|
||||
# CHECK: lima
|
||||
|
|
|
@ -43,6 +43,6 @@ expect_prompt()
|
|||
send("fooc \t")
|
||||
|
||||
expect_re(
|
||||
"alpha\W+india\W+hotel\W+charlie\W+echo\W+kilo\r\n"
|
||||
+ "bravo\W+foxtrot\W+golf\W+delta\W+juliett\W+lima"
|
||||
"india\W+hotel\W+charlie\W+alpha\W+delta\W+kilo\r\n"
|
||||
+ "foxtrot\W+golf\W+echo\W+bravo\W+juliett\W+lima"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue