mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-30 14:53:11 +00:00
parent
cc205a134b
commit
5bf21f2928
1 changed files with 7 additions and 2 deletions
|
@ -244,6 +244,9 @@ static bool compare_completions_by_duplicate_arguments(const completion_t &a,
|
||||||
return ad < bd;
|
return ad < bd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool compare_completions_by_tilde(const completion_t &a, const completion_t &b) {
|
||||||
|
return a.completion.back() == L'~' < b.completion.back() == L'~';
|
||||||
|
}
|
||||||
/// Unique the list of completions, without perturbing their order.
|
/// Unique the list of completions, without perturbing their order.
|
||||||
static void unique_completions_retaining_order(std::vector<completion_t> *comps) {
|
static void unique_completions_retaining_order(std::vector<completion_t> *comps) {
|
||||||
std::unordered_set<wcstring> seen;
|
std::unordered_set<wcstring> seen;
|
||||||
|
@ -285,9 +288,11 @@ void completions_sort_and_prioritize(std::vector<completion_t> *comps,
|
||||||
stable_sort(comps->begin(), comps->end(), compare_completions_by_match_type);
|
stable_sort(comps->begin(), comps->end(), compare_completions_by_match_type);
|
||||||
|
|
||||||
// Lastly, if this is for an autosuggestion, prefer to avoid completions that duplicate
|
// Lastly, if this is for an autosuggestion, prefer to avoid completions that duplicate
|
||||||
// arguments.
|
// arguments, and penalize files that end in tilde - they're frequently autosave files from e.g. emacs.
|
||||||
if (flags & completion_request_t::autosuggestion)
|
if (flags & completion_request_t::autosuggestion) {
|
||||||
stable_sort(comps->begin(), comps->end(), compare_completions_by_duplicate_arguments);
|
stable_sort(comps->begin(), comps->end(), compare_completions_by_duplicate_arguments);
|
||||||
|
stable_sort(comps->begin(), comps->end(), compare_completions_by_tilde);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Class representing an attempt to compute completions.
|
/// Class representing an attempt to compute completions.
|
||||||
|
|
Loading…
Reference in a new issue