aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar Tony Wang <wwwjfy@gmail.com>2013-08-18 10:43:13 +0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-08-25 19:33:39 -0700
commit7e1a3148fb373fc1c75c2350f1a256b4f06bea1f (patch)
treee668a65a71b2897cdeb904beaed2e6e2f429ffba /reader.cpp
parent5559962f6f584e3bce45e29676ef2d0c44e36124 (diff)
fixed fish-shell/fish-shell#944
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.
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/reader.cpp b/reader.cpp
index 80d60fb8..8045467e 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -1665,12 +1665,16 @@ static void prioritize_completions(std::vector<completion_t> &comp)
if (el.match.type < best_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. */
i = comp.size();
while (i--)
{
- if (comp.at(i).match.type != best_type)
+ if (comp.at(i).match.type > best_type)
{
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;
}
}
+ 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 */
bool will_replace_token = true;
for (size_t i=0; i< comp.size(); 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;
break;
@@ -1815,7 +1823,7 @@ static bool handle_completions(const std::vector<completion_t> &comp)
{
const completion_t &el = comp.at(i);
/* Only use completions with the best match type */
- if (el.match.type != best_match_type)
+ if (el.match.type > best_match_type)
continue;
/* Only use completions that match replace_token */