Revision: 2698
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2698&view=rev
Author:   hofman
Date:     2007-08-22 02:56:30 -0700 (Wed, 22 Aug 2007)

Log Message:
-----------
Fix matching of substring for type select. Add some comments.

Modified Paths:
--------------
    trunk/SKTypeSelectHelper.m

Modified: trunk/SKTypeSelectHelper.m
===================================================================
--- trunk/SKTypeSelectHelper.m  2007-08-21 23:55:47 UTC (rev 2697)
+++ trunk/SKTypeSelectHelper.m  2007-08-22 09:56:30 UTC (rev 2698)
@@ -266,21 +266,21 @@
     unsigned int stringLength = [string length];
     if (stringLength == 0 || stringLength > range.length)
         return NO;
-    if (mask & NSAnchoredSearch)
-        return [self rangeOfString:string options:mask range:range].length > 0;
-    NSRange searchRange = range;
-    while (searchRange.length >= stringLength) {
-        NSRange r = [self rangeOfString:string options:mask range:searchRange];
+    while (range.length >= stringLength) {
+        NSRange r = [self rangeOfString:string options:mask range:range];
         if (r.location == NSNotFound)
             return NO;
-        if (r.location == 0 || [[NSCharacterSet letterCharacterSet] 
characterIsMember:[self characterAtIndex:r.location - 1]])
+        // see if we start at a "word boundary"
+        if (r.location == 0 || [[NSCharacterSet alphanumericCharacterSet] 
characterIsMember:[self characterAtIndex:r.location - 1]] == NO)
             return YES;
+        // if it's anchored, we only should search once
+        if (mask & NSAnchoredSearch)
+            return NO;
+        // get the new range, shifted by one from the last match
         if (mask & NSBackwardsSearch)
-            searchRange = NSMakeRange(searchRange.location, NSMaxRange(r) - 
searchRange.location - 1);
+            range = NSMakeRange(range.location, NSMaxRange(r) - range.location 
- 1);
         else
-            searchRange = NSMakeRange(r.location + 1, NSMaxRange(searchRange) 
- r.location - 1);
-        if (mask & NSAnchoredSearch)
-            return NO;
+            range = NSMakeRange(r.location + 1, NSMaxRange(range) - r.location 
- 1);
     }
     return NO;
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to