Revision: 29090
          http://sourceforge.net/p/bibdesk/svn/29090
Author:   hofman
Date:     2025-03-02 09:02:19 +0000 (Sun, 02 Mar 2025)
Log Message:
-----------
restrict to requested group type later

Modified Paths:
--------------
    trunk/bibdesk/BibDocument+Scripting.m

Modified: trunk/bibdesk/BibDocument+Scripting.m
===================================================================
--- trunk/bibdesk/BibDocument+Scripting.m       2025-03-01 22:55:21 UTC (rev 
29089)
+++ trunk/bibdesk/BibDocument+Scripting.m       2025-03-02 09:02:19 UTC (rev 
29090)
@@ -720,12 +720,12 @@
     NSString *startKey = [startSpec key];
     NSString *endKey = [endSpec key];
     
-    if ((startSpec == nil) && (endSpec == nil))
+    if (startSpec == nil && endSpec == nil)
         // We need to have at least one of these...
         return [super scriptingValueForSpecifier:rangeSpec];
     
     if ([startSpec containerSpecifier] == nil && [startKey 
isEqualToString:key] && [endSpec containerSpecifier] == nil && [endKey 
isEqualToString:key])
-        // Just an ordinary range of (a type of) groups.  Let the scripting 
engine handle this.
+        // Just an regular range of (a type of) groups.  Let the scripting 
engine handle this.
         return [super scriptingValueForSpecifier:rangeSpec];
     
     if ((startSpec && [groupKeys() containsObject:startKey] == NO) || (endSpec 
&& [groupKeys() containsObject:endKey]) == NO)
@@ -733,8 +733,6 @@
         return [super scriptingValueForSpecifier:rangeSpec];
     
     NSArray *allGroups = [self scriptingGroups];
-    BOOL keyIsGroups = [key isEqual:@"scriptingGroups"];
-    NSArray *rangeKeyObjects = (keyIsGroups ? nil : [self valueForKey:key]);
     NSUInteger startIndex;
     NSUInteger endIndex;
     id object;
@@ -743,10 +741,6 @@
         // If there are no groups, there can be no match.  Just return now.
         return @[];
     
-    if (keyIsGroups == NO && [rangeKeyObjects count] == 0)
-        // If there are no groups for the key, there can be no match.  Just 
return now.
-        return @[];
-    
     // The strategy here is going to be to find the index of the start and 
stop object in the full groups array, regardless of what its key is.  Then we 
can find what we're looking for in that range of the groups key (weeding out 
objects we don't want, if necessary).
     
     // First find the index of the first start object in the groups array
@@ -801,7 +795,14 @@
     }
     
     // Now startIndex and endIndex specify the end points of the range we want 
within the groups array.
-    if (keyIsGroups == NO) {
+    
+    if ([key isEqual:@"scriptingGroups"] == NO) {
+        NSArray *rangeKeyObjects = [self valueForKey:key];
+        
+        if ([rangeKeyObjects count] == 0)
+            // If there are no groups for the key, there can be no match.  
Just return now.
+            return @[];
+        
         // Restrict to the requested group range
         NSUInteger rangeStartIndex = [allGroups 
indexOfObjectIdenticalTo:[rangeKeyObjects firstObject]];
         NSUInteger rangeEndIndex = [allGroups 
indexOfObjectIdenticalTo:[rangeKeyObjects lastObject]];
@@ -840,8 +841,6 @@
         // The base key is not a group key.
         return [super scriptingValueForSpecifier:relSpec];
 
-    NSInteger baseIndex;
-    
     // The strategy here is going to be to find the index of the base object 
in the full groups array, regardless of what its key is.  Then we can find what 
we're looking for before or after it.
     
     // First find the index of the first or last base object in the groups 
array
@@ -856,7 +855,7 @@
         return nil;
     }
     
-    baseIndex = [allGroups indexOfObjectIdenticalTo:baseObject];
+    NSInteger baseIndex = [allGroups indexOfObjectIdenticalTo:baseObject];
     if (baseIndex == NSNotFound) {
         // Oops.  We couldn't find the base object in the groups array.  This 
should not happen.
         [relSpec setEvaluationErrorNumber:NSInternalSpecifierError];

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