From 56dfd953fc8c4e59b2d9ddbce2cc7f89d13ac0f3 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 12 Jul 2011 00:00:57 +0000 Subject: - Support regex within the table filter list to match tables, falling back to plain text matching; thanks to Emma Persky for the original patch --- Source/SPTablesList.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Source') 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) -- cgit v1.2.3