diff --git a/ChangeLog b/ChangeLog index 44596e4fa..13033dc26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-07-21 Fred Kiefer + + * Source/NSTextView.m (-setTypingAttributes:): Make sure to keep + the main parts of the old attributes, if they are not provided by + the new ones. + 2006-07-18 23:11-EDT Gregory John Casamento * Source/GSNibCompatibility.m: Added category on NSView and diff --git a/Source/NSTextView.m b/Source/NSTextView.m index 7acc66dd9..4625c3dc4 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -2703,15 +2703,34 @@ This method is for user changes; see NSTextView_actions.m. - (void) setTypingAttributes: (NSDictionary *)attrs { + NSDictionary *old_attrs; + NSString *names[] = {NSParagraphStyleAttributeName, + NSFontAttributeName, + NSForegroundColorAttributeName}; + int i; + if (attrs == nil) { attrs = [isa defaultTypingAttributes]; } - DESTROY(_layoutManager->_typingAttributes); + old_attrs = _layoutManager->_typingAttributes; _layoutManager->_typingAttributes = [[NSMutableDictionary alloc] initWithDictionary: attrs]; + // make sure to keep the main attributes set. + for (i = 0; i < 3; i++) + { + NSString *name = names[i]; + + if ([attrs objectForKey: name] == nil) + { + [_layoutManager->_typingAttributes setObject: [old_attrs objectForKey: name] + forKey: name]; + } + } + RELEASE(old_attrs); + [self updateFontPanel]; [self updateRuler]; }