aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-03-07 22:20:41 +0100
committerMax <post@wickenrode.com>2015-03-07 22:20:41 +0100
commita9f5656e9649cf67bae7c6362bb5366f9dde3b44 (patch)
tree1f48ab34c2a90dc708569f9fdd62098ae80282d0
parent96b765ffbcb6c7fda058fbe8028b2e128007134a (diff)
downloadsequelpro-a9f5656e9649cf67bae7c6362bb5366f9dde3b44.tar.gz
sequelpro-a9f5656e9649cf67bae7c6362bb5366f9dde3b44.tar.bz2
sequelpro-a9f5656e9649cf67bae7c6362bb5366f9dde3b44.zip
Fuzzy search for "Go to database"
-rw-r--r--Source/SPGotoDatabaseController.m22
1 files changed, 14 insertions, 8 deletions
diff --git a/Source/SPGotoDatabaseController.m b/Source/SPGotoDatabaseController.m
index 5e8a4fb2..23b43ee2 100644
--- a/Source/SPGotoDatabaseController.m
+++ b/Source/SPGotoDatabaseController.m
@@ -185,21 +185,27 @@
nil];
for (NSString *db in unfilteredList) {
- // Let's just assume it is in the users interest (most of the time) for searches to be CI.
- NSRange match = [db rangeOfString:filter options:NSCaseInsensitiveSearch];
-
- if (match.location == NSNotFound) continue;
-
+
+ NSArray *matches = nil;
+ BOOL hasMatch = [db nonConsecutivelySearchString:filter matchingRanges:&matches];
+
+ if(!hasMatch) continue;
+
// Should we check for exact match AND have not yet found one?
if (exactMatch && !*exactMatch) {
- if (match.location == 0 && match.length == [db length]) {
- *exactMatch = YES;
+ if([matches count] == 1) {
+ NSRange match = [(NSValue *)[matches objectAtIndex:0] rangeValue];
+ if (match.location == 0 && match.length == [db length]) {
+ *exactMatch = YES;
+ }
}
}
NSMutableAttributedString *attrMatch = [[NSMutableAttributedString alloc] initWithString:db];
- [attrMatch setAttributes:attrs range:match];
+ for (NSValue *matchValue in matches) {
+ [attrMatch setAttributes:attrs range:[matchValue rangeValue]];
+ }
[filteredList addObject:[attrMatch autorelease]];
}