Prefer to not autosuggest existing arguments

This teaches autosuggestions to demote completions whose text matches an already
present argument.
This commit is contained in:
ridiculousfish
2018-08-07 02:01:19 -07:00
parent 459c01df76
commit 9c957eeef3
5 changed files with 75 additions and 12 deletions

View File

@@ -1180,9 +1180,10 @@ static std::function<autosuggestion_result_t(void)> get_autosuggestion_performer
if (wcschr(L"'\"", last_char) && cursor_at_end) return nothing;
// Try normal completions.
completion_request_flags_t complete_flags = COMPLETION_REQUEST_AUTOSUGGESTION;
std::vector<completion_t> completions;
complete(search_string, &completions, COMPLETION_REQUEST_AUTOSUGGESTION);
completions_sort_and_prioritize(&completions);
complete(search_string, &completions, complete_flags);
completions_sort_and_prioritize(&completions, complete_flags);
if (!completions.empty()) {
const completion_t &comp = completions.at(0);
size_t cursor = cursor_pos;