aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPGotoDatabaseController.h5
-rw-r--r--Source/SPGotoDatabaseController.m23
2 files changed, 22 insertions, 6 deletions
diff --git a/Source/SPGotoDatabaseController.h b/Source/SPGotoDatabaseController.h
index 99dfc289..453e5f25 100644
--- a/Source/SPGotoDatabaseController.h
+++ b/Source/SPGotoDatabaseController.h
@@ -29,7 +29,6 @@
// More info at <https://github.com/sequelpro/sequelpro>
#import <Cocoa/Cocoa.h>
-@class SPDatabaseDocument;
/**
* This class provides a dialog with a single-column table view and a
@@ -58,10 +57,10 @@
/**
* Set the list of databases the user can pick from.
- * @param list An array of NSStrings
+ * @param list An array of NSStrings, will be shallow-copied
*
* This method must be called before runModal. The list will not be updated
- * when the dialog is on screen.
+ * while the dialog is on screen.
*/
- (void)setDatabaseList:(NSArray *)list;
diff --git a/Source/SPGotoDatabaseController.m b/Source/SPGotoDatabaseController.m
index 0c6cbef0..a038cd8b 100644
--- a/Source/SPGotoDatabaseController.m
+++ b/Source/SPGotoDatabaseController.m
@@ -29,9 +29,19 @@
// More info at <https://github.com/sequelpro/sequelpro>
#import "SPGotoDatabaseController.h"
-#import "SPDatabaseDocument.h"
@interface SPGotoDatabaseController (Private)
+
+/** Update the list of matched names
+ * @param filter The string to be matched.
+ * @param exactMatch Will be set to YES if there is at least one entry in
+ * unfilteredList that is equivalent to filter. Can be NULL to disable.
+ *
+ * This method will take every item in the unfilteredList and add matching items
+ * to the filteredList, including highlighting.
+ * It will neither clear the filteredList first, nor change the isFiltered ivar!
+ * Search is case insensitive.
+ */
- (void)_buildHightlightedFilterList:(NSString *)filter didFindExactMatch:(BOOL *)exactMatch;
- (IBAction)okClicked:(id)sender;
@@ -53,6 +63,12 @@
return self;
}
+- (void)windowDidLoad {
+ //handle a double click in the DB list the same as if OK was clicked.
+ [databaseListView setTarget:self];
+ [databaseListView setDoubleAction:@selector(okClicked:)];
+}
+
#pragma mark -
#pragma mark IBAction
@@ -145,10 +161,11 @@
nil];
for(NSString *db in unfilteredList) {
- NSRange match = [db rangeOfString:filter];
+ //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;
- //check for exact match?
+ //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;