diff options
author | Tony Wang <wwwjfy@gmail.com> | 2013-08-18 10:43:13 +0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-08-25 19:33:39 -0700 |
commit | 7e1a3148fb373fc1c75c2350f1a256b4f06bea1f (patch) | |
tree | e668a65a71b2897cdeb904beaed2e6e2f429ffba /reader.cpp | |
parent | 5559962f6f584e3bce45e29676ef2d0c44e36124 (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.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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 */ |