Revision: 29381 http://sourceforge.net/p/bibdesk/svn/29381 Author: hofman Date: 2025-07-28 09:37:16 +0000 (Mon, 28 Jul 2025) Log Message: ----------- handle removal of fragile cite key characters in error recovery callback
Modified Paths: -------------- trunk/bibdesk/BDSKEditor.m Modified: trunk/bibdesk/BDSKEditor.m =================================================================== --- trunk/bibdesk/BDSKEditor.m 2025-07-28 09:27:31 UTC (rev 29380) +++ trunk/bibdesk/BDSKEditor.m 2025-07-28 09:37:16 UTC (rev 29381) @@ -525,9 +525,9 @@ } - (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(void *)contextInfo { - NSTextView *textView = (NSTextView *)[citeKeyField currentEditor]; - if (textView) { - if (didRecover) { + if (didRecover) { + NSTextView *textView = (NSTextView *)[citeKeyField currentEditor]; + if (textView) { // we must be committing the citeKeyField with fragile characters NSArray *selection = [textView selectedRanges]; editorFlags.allowFragileCharacters = YES; @@ -536,9 +536,6 @@ else if ([[self window] makeFirstResponder:citeKeyField]) [(NSTextView *)[citeKeyField currentEditor] setSafeSelectedRanges:selection]; editorFlags.allowFragileCharacters = NO; - } else { - NSCharacterSet *invalidSet = [[BDSKTypeManager sharedManager] fragileCiteKeyCharacterSet]; - [citeKeyField setStringValue:[[textView string] stringByReplacingCharactersInSet:invalidSet withString:@""]]; } } NSInvocation *invocation = (NSInvocation *)CFBridgingRelease(contextInfo); @@ -2083,6 +2080,14 @@ } - (BOOL)attemptRecoveryFromError:(NSError *)error optionIndex:(NSUInteger)recoveryOptionIndex { + if (recoveryOptionIndex == 0) { + NSText *text = [citeKeyField currentEditor]; + if (text) { + // user said to remove fragile characters + NSCharacterSet *invalidSet = [[BDSKTypeManager sharedManager] fragileCiteKeyCharacterSet]; + [citeKeyField setStringValue:[[text string] stringByReplacingCharactersInSet:invalidSet withString:@""]]; + } + } return recoveryOptionIndex == 1; } @@ -2171,16 +2176,10 @@ if (isValid) return YES; - if ([err localizedRecoveryOptions]) { + if ([err localizedRecoveryOptions]) isValid = [self presentError:err]; - if (control == citeKeyField && isValid == NO) { - // user said to remove fragile characters - NSCharacterSet *invalidSet = [[BDSKTypeManager sharedManager] fragileCiteKeyCharacterSet]; - [control setStringValue:[obj stringByReplacingCharactersInSet:invalidSet withString:@""]]; - } - } else { + else [self presentError:err modalForWindow:[self window] delegate:nil didPresentSelector:NULL contextInfo:NULL]; - } return isValid; } 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