You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Change fuzzy search to only set case sensitive within set_query
This commit is contained in:
@@ -265,12 +265,19 @@ void FuzzySearch::sort_and_filter(Vector<FuzzySearchResult> &p_results) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FuzzySearch::set_query(const String &p_query) {
|
void FuzzySearch::set_query(const String &p_query) {
|
||||||
tokens.clear();
|
set_query(p_query, !p_query.is_lowercase());
|
||||||
for (const String &string : p_query.split(" ", false)) {
|
|
||||||
tokens.append({ static_cast<int>(tokens.size()), string });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case_sensitive = !p_query.is_lowercase();
|
void FuzzySearch::set_query(const String &p_query, bool p_case_sensitive) {
|
||||||
|
tokens.clear();
|
||||||
|
case_sensitive = p_case_sensitive;
|
||||||
|
|
||||||
|
for (const String &string : p_query.split(" ", false)) {
|
||||||
|
tokens.append({
|
||||||
|
static_cast<int>(tokens.size()),
|
||||||
|
p_case_sensitive ? string : string.to_lower(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
struct TokenComparator {
|
struct TokenComparator {
|
||||||
bool operator()(const FuzzySearchToken &A, const FuzzySearchToken &B) const {
|
bool operator()(const FuzzySearchToken &A, const FuzzySearchToken &B) const {
|
||||||
|
|||||||
@@ -84,16 +84,17 @@ public:
|
|||||||
class FuzzySearch {
|
class FuzzySearch {
|
||||||
Vector<FuzzySearchToken> tokens;
|
Vector<FuzzySearchToken> tokens;
|
||||||
|
|
||||||
|
bool case_sensitive = false;
|
||||||
void sort_and_filter(Vector<FuzzySearchResult> &p_results) const;
|
void sort_and_filter(Vector<FuzzySearchResult> &p_results) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int start_offset = 0;
|
int start_offset = 0;
|
||||||
bool case_sensitive = false;
|
|
||||||
int max_results = 100;
|
int max_results = 100;
|
||||||
int max_misses = 2;
|
int max_misses = 2;
|
||||||
bool allow_subsequences = true;
|
bool allow_subsequences = true;
|
||||||
|
|
||||||
void set_query(const String &p_query);
|
void set_query(const String &p_query);
|
||||||
|
void set_query(const String &p_query, bool p_case_sensitive);
|
||||||
bool search(const String &p_target, FuzzySearchResult &p_result) const;
|
bool search(const String &p_target, FuzzySearchResult &p_result) const;
|
||||||
void search_all(const PackedStringArray &p_targets, Vector<FuzzySearchResult> &p_results) const;
|
void search_all(const PackedStringArray &p_targets, Vector<FuzzySearchResult> &p_results) const;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user