diff options
author | 2013-08-31 15:01:02 -0700 | |
---|---|---|
committer | 2013-08-31 15:01:02 -0700 | |
commit | c38a40d1930d0af2f0d078896fe02fd0bee5fabd (patch) | |
tree | 2e70a5cbdd863bde7373ffaa9972a0cd5aaa0c10 /reader.cpp | |
parent | 23ba7b5bfff9393d222cd8e4a045e3439e24aba1 (diff) |
Adjust prefix completions to sort alphabetically instead of by length.
Other completions are still sorted by length.
https://github.com/fish-shell/fish-shell/issues/923
Diffstat (limited to 'reader.cpp')
-rw-r--r-- | reader.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -802,8 +802,8 @@ bool reader_data_t::expand_abbreviation_as_necessary(size_t cursor_backtrack) /** Sorts and remove any duplicate completions in the list. */ static void sort_and_make_unique(std::vector<completion_t> &l) { - sort(l.begin(), l.end()); - l.erase(std::unique(l.begin(), l.end()), l.end()); + sort(l.begin(), l.end(), completion_t::is_alphabetically_less_than); + l.erase(std::unique(l.begin(), l.end(), completion_t::is_alphabetically_equal_to), l.end()); } @@ -1642,11 +1642,14 @@ static bool reader_can_replace(const wcstring &in, int flags) /* Compare two completions, ordering completions with better match types first */ bool compare_completions_by_match_type(const completion_t &a, const completion_t &b) { - /* Compare match types */ - int match_compare = a.match.compare(b.match); - if (match_compare != 0) + /* Compare match types, unless both completions are prefix (#923) in which case we always want to compare them alphabetically */ + if (a.match.type != fuzzy_match_prefix || b.match.type != fuzzy_match_prefix) { - return match_compare < 0; + int match_compare = a.match.compare(b.match); + if (match_compare != 0) + { + return match_compare < 0; + } } /* Compare using file comparison */ |