Revision: 22438
http://sourceforge.net/p/bibdesk/svn/22438
Author: hofman
Date: 2018-07-18 21:30:36 +0000 (Wed, 18 Jul 2018)
Log Message:
-----------
make sure the attributed string is updated in the format before recoloring,
also keeps the error up to date, may not happen otherwise e.g. with undo
Modified Paths:
--------------
trunk/bibdesk/BibPref_AutoFile.m
trunk/bibdesk/BibPref_CiteKey.m
Modified: trunk/bibdesk/BibPref_AutoFile.m
===================================================================
--- trunk/bibdesk/BibPref_AutoFile.m 2018-07-18 12:33:27 UTC (rev 22437)
+++ trunk/bibdesk/BibPref_AutoFile.m 2018-07-18 21:30:36 UTC (rev 22438)
@@ -328,11 +328,16 @@
- (void)recolorFormatField {
NSTextView *fieldEditor = (NSTextView *)[formatSheetField currentEditor];
+ if (fieldEditor == nil)
+ return;
// get the attributed string from the format parser
- NSAttributedString *attrString = [(BDSKFormatStringFormatter
*)[formatSheetField formatter] attributedString];
-
+ BDSKFormatStringFormatter *formatter = (BDSKFormatStringFormatter
*)[formatSheetField formatter];
+ NSAttributedString *attrString = [formatter attributedString];
+ NSString *string = [fieldEditor string];
// get the attributes of the parsed string and apply them to our
NSTextStorage; it may not be safe to set it directly at this point
- if ([[fieldEditor string] isEqualToString:[attrString string]]) {
+ if ([string isEqualToString:[attrString string]] == NO)
+ attrString = [formatter attributedStringForObjectValue:[fieldEditor
string] withDefaultAttributes:nil];
+ if ([string isEqualToString:[attrString string]]) {
NSTextStorage *textStorage = [fieldEditor textStorage];
[attrString enumerateAttributesInRange:NSMakeRange(0, [attrString
length]) options:0 usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop){
[textStorage addAttributes:attrs range:range];
Modified: trunk/bibdesk/BibPref_CiteKey.m
===================================================================
--- trunk/bibdesk/BibPref_CiteKey.m 2018-07-18 12:33:27 UTC (rev 22437)
+++ trunk/bibdesk/BibPref_CiteKey.m 2018-07-18 21:30:36 UTC (rev 22438)
@@ -239,10 +239,16 @@
- (void)recolorFormatField {
NSTextView *fieldEditor = (NSTextView *)[formatSheetField currentEditor];
+ if (fieldEditor == nil)
+ return;
// get the attributed string from the format parser
- NSAttributedString *attrString = [(BDSKFormatStringFormatter
*)[formatSheetField formatter] attributedString];
+ BDSKFormatStringFormatter *formatter = (BDSKFormatStringFormatter
*)[formatSheetField formatter];
+ NSAttributedString *attrString = [formatter attributedString];
+ NSString *string = [fieldEditor string];
// get the attributes of the parsed string and apply them to our
NSTextStorage; it may not be safe to set it directly at this point
- if ([[fieldEditor string] isEqualToString:[attrString string]]) {
+ if ([string isEqualToString:[attrString string]] == NO)
+ attrString = [formatter attributedStringForObjectValue:[fieldEditor
string] withDefaultAttributes:nil];
+ if ([string isEqualToString:[attrString string]]) {
NSTextStorage *textStorage = [fieldEditor textStorage];
[attrString enumerateAttributesInRange:NSMakeRange(0, [attrString
length]) options:0 usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop){
[textStorage addAttributes:attrs range:range];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit