From 6e525cc5d946965a31f74a28ab4dcb20cf01c11d Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Sat, 16 Mar 2019 01:08:21 -0700 Subject: [PATCH] wcsfilecmp: sort - after everything else Before this change, - was sorted with other punctuation before A-Z. Now, it sorts above the rest of the characters. This has a practical effect on completions, where when there are both -s and --long with the same description, the short option is now before the long option in the pager, which is what is now selected when navigating `foo -`. The long options can be picked out with `foo --`. Before, short options which duplicated a long option literally could not be selected by any means from the pager. Fixes #5634 --- src/util.cpp | 3 +++ tests/__fish_complete_directories.out | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 4ca1cec54..0ca0ac7b2 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -63,6 +63,9 @@ int wcsfilecmp(const wchar_t *a, const wchar_t *b) { wint_t al = towupper(*a); wint_t bl = towupper(*b); + if (al == L'-') al += 48; + if (bl == L'-') bl += 48; + if (al < bl) { retval = -1; break; diff --git a/tests/__fish_complete_directories.out b/tests/__fish_complete_directories.out index a19636ac4..6d72a4d55 100644 --- a/tests/__fish_complete_directories.out +++ b/tests/__fish_complete_directories.out @@ -6,9 +6,9 @@ test/data/ Directory # __fish_complete_directories test/data/ test/data/abc/ Directory test/data/abcd/ Directory +test/data/fish/ Directory test/data/fish-symlink/ Directory test/data/fish-symlink2/ Directory -test/data/fish/ Directory test/data/xy/ Directory test/data/xyz/ Directory # __fish_complete_directories test/data/abc