diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index e38212981..c55d3dccf 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1313,6 +1313,15 @@ var kDelegateRespondsTo_textShouldBeginEditing [self insertLineBreak:sender]; } +- (void)_enrichEssentialTypingAttributes:(CPDictionary)attributes +{ + if (![attributes containsKey:CPFontAttributeName]) + [attributes setObject:[self font] forKey:CPFontAttributeName]; + + if (![attributes containsKey:CPForegroundColorAttributeName]) + [attributes setObject:[self textColor] forKey:CPForegroundColorAttributeName]; +} + - (void)setTypingAttributes:(CPDictionary)attributes { if (!attributes) @@ -1326,12 +1335,7 @@ var kDelegateRespondsTo_textShouldBeginEditing { _typingAttributes = [attributes copy]; - /* check that new attributes contains essentials one's */ - if (![_typingAttributes containsKey:CPFontAttributeName]) - [_typingAttributes setObject:[self font] forKey:CPFontAttributeName]; - - if (![_typingAttributes containsKey:CPForegroundColorAttributeName]) - [_typingAttributes setObject:[self textColor] forKey:CPForegroundColorAttributeName]; + [self _enrichEssentialTypingAttributes:_typingAttributes]; } [[CPNotificationCenter defaultCenter] postNotificationName:CPTextViewDidChangeTypingAttributesNotification @@ -1345,8 +1349,7 @@ var kDelegateRespondsTo_textShouldBeginEditing { var attributes = [[_textStorage attributesAtIndex:CPMaxRange(_selectionRange) effectiveRange:nil] copy]; - if (![attributes containsKey:CPForegroundColorAttributeName]) - [attributes setObject:[self textColor] forKey:CPForegroundColorAttributeName]; + [self _enrichEssentialTypingAttributes:attributes]; return attributes; }