Revision: 14493
          http://sourceforge.net/p/skim-app/code/14493
Author:   hofman
Date:     2024-09-30 08:53:42 +0000 (Mon, 30 Sep 2024)
Log Message:
-----------
Check whole word match in whole string of page rather than strings of extended 
selection. It looks like PDFSelection caches the string and does not update it 
when it is extended.

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

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2024-09-29 16:08:55 UTC (rev 14492)
+++ trunk/SKMainWindowController.m      2024-09-30 08:53:42 UTC (rev 14493)
@@ -1924,26 +1924,21 @@
 #pragma mark PDFDocument delegate
 
 - (void)didMatchString:(PDFSelection *)instance {
+    PDFPage *page = [instance safeFirstPage];
+    // this should never happen, but apparently PDFKit sometimes does return 
empty matches
+    if (page == nil)
+        return;
+    
     if (mwcFlags.wholeWordSearch) {
-        PDFSelection *copy = [instance copy];
-        NSString *string = [instance string];
-        NSUInteger l = [string length];
-        [copy extendSelectionAtEnd:1];
-        string = [copy string];
-        if ([string length] > l && [[NSCharacterSet letterCharacterSet] 
characterIsMember:[string characterAtIndex:l]])
+        NSString *string = [page string];
+        NSUInteger i = [instance safeIndexOfFirstCharacterOnPage:page];
+        if (i > 0 && [[NSCharacterSet letterCharacterSet] 
characterIsMember:[string characterAtIndex:i - 1]])
             return;
-        l = [string length];
-        [copy extendSelectionAtStart:1];
-        string = [copy string];
-        if ([string length] > l && [[NSCharacterSet letterCharacterSet] 
characterIsMember:[string characterAtIndex:0]])
+        i = [instance safeIndexOfLastCharacterOnPage:page];
+        if (i + 1 < [string length] && [[NSCharacterSet letterCharacterSet] 
characterIsMember:[string characterAtIndex:i + 1]])
             return;
     }
     
-    PDFPage *page = [instance safeFirstPage];
-    // this should never happen, but apparently PDFKit sometimes does return 
empty matches
-    if (page == nil)
-        return;
-    
     NSUInteger pageIndex = [page pageIndex];
     CGFloat order = [instance boundsOrderForPage:page];
     NSInteger i = [searchResults count];

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to