mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
When the completion list includes the exact typed string with other candidates, i.e. completion_t.match.type == fuzzy_match_exact, the other candidates will be removed from the list, as they are not the "best type". This is inconvenient for the user who wants to type and complete commands in the other candidates. The commit is to make the best_type to fuzzy_match_prefix as highest priority, also, when comparing to best_type, the same or higher priority completions can both match.
This commit is contained in:
parent
5559962f6f
commit
7e1a3148fb
1 changed files with 11 additions and 3 deletions
14
reader.cpp
14
reader.cpp
|
@ -1665,12 +1665,16 @@ static void prioritize_completions(std::vector<completion_t> &comp)
|
||||||
if (el.match.type < best_type)
|
if (el.match.type < best_type)
|
||||||
best_type = el.match.type;
|
best_type = el.match.type;
|
||||||
}
|
}
|
||||||
|
if (best_type == fuzzy_match_exact)
|
||||||
|
{
|
||||||
|
best_type = fuzzy_match_prefix;
|
||||||
|
}
|
||||||
|
|
||||||
/* Throw out completions whose match types are not the best. */
|
/* Throw out completions whose match types are not the best. */
|
||||||
i = comp.size();
|
i = comp.size();
|
||||||
while (i--)
|
while (i--)
|
||||||
{
|
{
|
||||||
if (comp.at(i).match.type != best_type)
|
if (comp.at(i).match.type > best_type)
|
||||||
{
|
{
|
||||||
comp.erase(comp.begin() + i);
|
comp.erase(comp.begin() + i);
|
||||||
}
|
}
|
||||||
|
@ -1796,13 +1800,17 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||||
best_match_type = el.match.type;
|
best_match_type = el.match.type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (best_match_type == fuzzy_match_exact)
|
||||||
|
{
|
||||||
|
best_match_type = fuzzy_match_prefix;
|
||||||
|
}
|
||||||
|
|
||||||
/* Determine whether we are going to replace the token or not. If any commands of the best type do not require replacement, then ignore all those that want to use replacement */
|
/* Determine whether we are going to replace the token or not. If any commands of the best type do not require replacement, then ignore all those that want to use replacement */
|
||||||
bool will_replace_token = true;
|
bool will_replace_token = true;
|
||||||
for (size_t i=0; i< comp.size(); i++)
|
for (size_t i=0; i< comp.size(); i++)
|
||||||
{
|
{
|
||||||
const completion_t &el = comp.at(i);
|
const completion_t &el = comp.at(i);
|
||||||
if (el.match.type == best_match_type && !(el.flags & COMPLETE_REPLACES_TOKEN))
|
if (el.match.type <= best_match_type && !(el.flags & COMPLETE_REPLACES_TOKEN))
|
||||||
{
|
{
|
||||||
will_replace_token = false;
|
will_replace_token = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1815,7 +1823,7 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||||
{
|
{
|
||||||
const completion_t &el = comp.at(i);
|
const completion_t &el = comp.at(i);
|
||||||
/* Only use completions with the best match type */
|
/* Only use completions with the best match type */
|
||||||
if (el.match.type != best_match_type)
|
if (el.match.type > best_match_type)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Only use completions that match replace_token */
|
/* Only use completions that match replace_token */
|
||||||
|
|
Loading…
Reference in a new issue