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.
|
// Both completions are from a source with the --keep-order flag.
|
||||||
return Ordering::Equal;
|
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)
|
wcsfilecmp(&a.completion, &b.completion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,15 @@ complete -c fooc -fa "kilo juliett lima"
|
||||||
|
|
||||||
# Generate completions
|
# Generate completions
|
||||||
complete -C"fooc "
|
complete -C"fooc "
|
||||||
# CHECK: alpha
|
|
||||||
# CHECK: bravo
|
|
||||||
# CHECK: india
|
# CHECK: india
|
||||||
# CHECK: foxtrot
|
# CHECK: foxtrot
|
||||||
# CHECK: hotel
|
# CHECK: hotel
|
||||||
# CHECK: golf
|
# CHECK: golf
|
||||||
# CHECK: charlie
|
# CHECK: charlie
|
||||||
# CHECK: delta
|
|
||||||
# CHECK: echo
|
# CHECK: echo
|
||||||
|
# CHECK: alpha
|
||||||
|
# CHECK: bravo
|
||||||
|
# CHECK: delta
|
||||||
# CHECK: juliett
|
# CHECK: juliett
|
||||||
# CHECK: kilo
|
# CHECK: kilo
|
||||||
# CHECK: lima
|
# CHECK: lima
|
||||||
|
|
|
@ -43,6 +43,6 @@ expect_prompt()
|
||||||
send("fooc \t")
|
send("fooc \t")
|
||||||
|
|
||||||
expect_re(
|
expect_re(
|
||||||
"alpha\W+india\W+hotel\W+charlie\W+echo\W+kilo\r\n"
|
"india\W+hotel\W+charlie\W+alpha\W+delta\W+kilo\r\n"
|
||||||
+ "bravo\W+foxtrot\W+golf\W+delta\W+juliett\W+lima"
|
+ "foxtrot\W+golf\W+echo\W+bravo\W+juliett\W+lima"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue