mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
Don't open pager with only one completion
Since smartcase, we could land in a situation where we offer one option in the pager, which is awkward. So detect this and just insert the option directly, we can add any more smartness later. Fixes #7738.
This commit is contained in:
parent
050fd342da
commit
d0a8493844
1 changed files with 17 additions and 0 deletions
|
@ -1948,6 +1948,23 @@ bool reader_data_t::handle_completions(const completion_list_t &comp, size_t tok
|
|||
all_matches_exact_or_prefix = all_matches_exact_or_prefix && el.match.is_exact_or_prefix();
|
||||
}
|
||||
|
||||
if (surviving_completions.size() == 1) {
|
||||
// After sorting and stuff only one completion is left, use it.
|
||||
//
|
||||
// TODO: This happens when smartcase kicks in, e.g.
|
||||
// the token is "cma" and the options are "cmake/" and "CMakeLists.txt"
|
||||
// it would be nice if we could figure
|
||||
// out how to use it more.
|
||||
const completion_t &c = surviving_completions.at(0);
|
||||
|
||||
// If this is a replacement completion, check that we know how to replace it, e.g. that
|
||||
// the token doesn't contain evil operators like {}.
|
||||
if (!(c.flags & COMPLETE_REPLACES_TOKEN) || reader_can_replace(tok, c.flags)) {
|
||||
completion_insert(c.completion, token_end, c.flags);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool use_prefix = false;
|
||||
wcstring common_prefix;
|
||||
if (all_matches_exact_or_prefix) {
|
||||
|
|
Loading…
Reference in a new issue