diff options
author | rowanbeentje <rowan@beent.je> | 2011-07-12 00:00:57 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2011-07-12 00:00:57 +0000 |
commit | 56dfd953fc8c4e59b2d9ddbce2cc7f89d13ac0f3 (patch) | |
tree | 0be61e7177240412c46d35adbce22976f2709cda /Source | |
parent | fa36e8280a3e3b02bbb39c152bd08061b302f168 (diff) | |
download | sequelpro-56dfd953fc8c4e59b2d9ddbce2cc7f89d13ac0f3.tar.gz sequelpro-56dfd953fc8c4e59b2d9ddbce2cc7f89d13ac0f3.tar.bz2 sequelpro-56dfd953fc8c4e59b2d9ddbce2cc7f89d13ac0f3.zip |
- Support regex within the table filter list to match tables, falling back to plain text matching; thanks to Emma Persky for the original patch
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPTablesList.m | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index d2d9f494..6cbf5f82 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -1809,11 +1809,16 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; NSUInteger i; NSInteger lastTableType = NSNotFound, tableType; NSRange substringRange; + NSString *filterString = [listFilterField stringValue]; for (i = 0; i < [tables count]; i++) { tableType = [[tableTypes objectAtIndex:i] integerValue]; if (tableType == SPTableTypeNone) continue; - substringRange = [[tables objectAtIndex:i] rangeOfString:[listFilterField stringValue] options:NSCaseInsensitiveSearch]; - if (substringRange.location == NSNotFound) continue; + + // First check the table name against the string as a regex, falling back to direct string match + if (![[tables objectAtIndex:i] isMatchedByRegex:filterString]) { + substringRange = [[tables objectAtIndex:i] rangeOfString:filterString options:NSCaseInsensitiveSearch]; + if (substringRange.location == NSNotFound) continue; + } // Add a title if necessary if ((tableType == SPTableTypeTable || tableType == SPTableTypeView) && lastTableType == NSNotFound) |