mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
Bravely remove string_fuzzy_match_t::compare
This is used to decide which fuzzy match is better, however it is used only in wildcard expansion and not in actual completion ranking or anywhere else where it could matter. Try removing the compare() call and implementation. What compare() did specially was compare distances, e.g. it ranks lib as better than libexec when expanding /u/l/b. But the tests did not exercise this so it's hard to know if it's working. In preparation for a refactoring, remove it.
This commit is contained in:
parent
ac1ee6f1fd
commit
20b98294ba
3 changed files with 2 additions and 23 deletions
|
@ -202,25 +202,6 @@ string_fuzzy_match_t string_fuzzy_match_string(const wcstring &string,
|
|||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline int compare_ints(T a, T b) {
|
||||
if (a < b) return -1;
|
||||
if (a == b) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// Compare types; if the types match, compare distances.
|
||||
int string_fuzzy_match_t::compare(const string_fuzzy_match_t &rhs) const {
|
||||
if (this->type != rhs.type) {
|
||||
return compare_ints(this->type, rhs.type);
|
||||
} else if (this->match_distance_first != rhs.match_distance_first) {
|
||||
return compare_ints(this->match_distance_first, rhs.match_distance_first);
|
||||
} else if (this->match_distance_second != rhs.match_distance_second) {
|
||||
return compare_ints(this->match_distance_second, rhs.match_distance_second);
|
||||
}
|
||||
return 0; // equal
|
||||
}
|
||||
|
||||
template <bool Fuzzy, typename T>
|
||||
size_t ifind_impl(const T &haystack, const T &needle) {
|
||||
using char_t = typename T::value_type;
|
||||
|
|
|
@ -111,9 +111,6 @@ struct string_fuzzy_match_t {
|
|||
// Constructor.
|
||||
explicit string_fuzzy_match_t(enum fuzzy_type_t t, size_t distance_first = 0,
|
||||
size_t distance_second = 0);
|
||||
|
||||
// Return -1, 0, 1 if this match is (respectively) better than, equal to, or worse than rhs.
|
||||
int compare(const string_fuzzy_match_t &rhs) const;
|
||||
};
|
||||
|
||||
/// Compute a fuzzy match for a string. If maximum_match is not fuzzy_match_t::none, limit the type
|
||||
|
|
|
@ -851,7 +851,8 @@ void wildcard_expander_t::expand_literal_intermediate_segment_with_fuzz(const wc
|
|||
c->prepend_token_prefix(child_prefix);
|
||||
}
|
||||
// And every match must be made at least as fuzzy as ours.
|
||||
if (match.compare(c->match) > 0) {
|
||||
// TODO: justify this, tests do not exercise it yet.
|
||||
if (match.type > c->match.type) {
|
||||
// Our match is fuzzier.
|
||||
c->match = match;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue