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) {
 | 
			
		||||
	tokens.clear();
 | 
			
		||||
	for (const String &string : p_query.split(" ", false)) {
 | 
			
		||||
		tokens.append({ static_cast<int>(tokens.size()), string });
 | 
			
		||||
	}
 | 
			
		||||
	set_query(p_query, !p_query.is_lowercase());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
	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 {
 | 
			
		||||
		bool operator()(const FuzzySearchToken &A, const FuzzySearchToken &B) const {
 | 
			
		||||
 
 | 
			
		||||
@@ -84,16 +84,17 @@ public:
 | 
			
		||||
class FuzzySearch {
 | 
			
		||||
	Vector<FuzzySearchToken> tokens;
 | 
			
		||||
 | 
			
		||||
	bool case_sensitive = false;
 | 
			
		||||
	void sort_and_filter(Vector<FuzzySearchResult> &p_results) const;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	int start_offset = 0;
 | 
			
		||||
	bool case_sensitive = false;
 | 
			
		||||
	int max_results = 100;
 | 
			
		||||
	int max_misses = 2;
 | 
			
		||||
	bool allow_subsequences = true;
 | 
			
		||||
 | 
			
		||||
	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;
 | 
			
		||||
	void search_all(const PackedStringArray &p_targets, Vector<FuzzySearchResult> &p_results) const;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user