Revision: 29072 http://sourceforge.net/p/bibdesk/svn/29072 Author: hofman Date: 2025-02-26 22:10:34 +0000 (Wed, 26 Feb 2025) Log Message: ----------- return single group from relative specifier
Modified Paths: -------------- trunk/bibdesk/BibDocument+Scripting.m Modified: trunk/bibdesk/BibDocument+Scripting.m =================================================================== --- trunk/bibdesk/BibDocument+Scripting.m 2025-02-26 15:50:10 UTC (rev 29071) +++ trunk/bibdesk/BibDocument+Scripting.m 2025-02-26 22:10:34 UTC (rev 29072) @@ -829,7 +829,7 @@ if ([allGroups count] == 0) // If there are no groups, there can be no match. Just return now. - return @[]; + return [NSNull null]; if ([groupKeys() containsObject:baseKey]) { NSInteger baseIndex; @@ -857,7 +857,6 @@ // Now baseIndex specifies the base object for the relative spec in the groups array. // We will start either right before or right after and look for an object that matches the type we want. // We do this by getting each object and seeing if it actually appears in the real key that we are trying to evaluate in. - NSMutableArray *result = [NSMutableArray array]; BOOL keyIsGroups = [key isEqual:@"scriptingGroups"]; NSArray *relKeyObjects = (keyIsGroups ? nil : [self valueForKey:key]); id curObj; @@ -871,10 +870,8 @@ while ((baseIndex >= 0) && (baseIndex < groupCount)) { curObj = [allGroups objectAtIndex:baseIndex]; - if (keyIsGroups || [relKeyObjects containsObject:curObj]) { - [result addObject:curObj]; - break; - } + if (keyIsGroups || [relKeyObjects containsObject:curObj]) + return curObj; if (relPos == NSRelativeBefore) baseIndex--; else @@ -881,7 +878,7 @@ baseIndex++; } - return result; + return [NSNull null]; } } return nil; @@ -897,7 +894,7 @@ else if ([specifier isKindOfClass:[NSRelativeSpecifier class]]) result = [self scriptingValueForRelativeSpecifier:(NSRelativeSpecifier *)specifier]; - return result ?: [super scriptingValueForSpecifier:specifier]; + return result == [NSNull null] ? nil : (result ?: [super scriptingValueForSpecifier:specifier]); } #pragma mark Commands 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