Revision: 28867
          http://sourceforge.net/p/bibdesk/svn/28867
Author:   hofman
Date:     2024-04-26 15:53:50 +0000 (Fri, 26 Apr 2024)
Log Message:
-----------
find fully matched completion in matching loop

Modified Paths:
--------------
    trunk/bibdesk/BDSKCompletionManager.m

Modified: trunk/bibdesk/BDSKCompletionManager.m
===================================================================
--- trunk/bibdesk/BDSKCompletionManager.m       2024-04-26 14:35:51 UTC (rev 
28866)
+++ trunk/bibdesk/BDSKCompletionManager.m       2024-04-26 15:53:50 UTC (rev 
28867)
@@ -244,24 +244,22 @@
     NSSet *strings = [autoCompletionDict objectForKey:entry];
     NSMutableArray *completions = [NSMutableArray array];
     BOOL isAuthor = [entry isEqualToString:BDSKAuthorString];
+    NSString *matched = nil;
 
     for (NSString *string in strings) {
-        if ([[string stringByRemovingCurlyBraces] 
hasCaseInsensitivePrefix:matchString] ||
-            (isAuthor && [[lastNamesDict objectForKey:string] 
hasCaseInsensitivePrefix:matchString]))
+        NSString *cleanString = [string stringByRemovingCurlyBraces];
+        if ([cleanString hasCaseInsensitivePrefix:matchString] ||
+            (isAuthor && [[lastNamesDict objectForKey:string] 
hasCaseInsensitivePrefix:matchString])) {
+            if (matched == nil && [cleanString 
isCaseInsensitiveEqual:matchString])
+                matched = string;
             [completions addObject:string];
+        }
     }
     
     [completions 
sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
     
-    __block NSInteger theIdx = -1;
-    [completions enumerateObjectsUsingBlock:^(NSString *str, NSUInteger i, 
BOOL *stop){
-        if ([[str stringByRemovingCurlyBraces] 
isCaseInsensitiveEqual:matchString] == NO) {
-            theIdx = i;
-            *stop = YES;
-        }
-    }];
-    if (theIdx >= 0)
-        *idx = theIdx;
+    if (matched)
+        *idx = [completions indexOfObject:matched];
     
     return completions;
 }

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to