diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 093bbfcc5..a5d1fa650 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1479,6 +1479,12 @@ var kDelegateRespondsTo_textShouldBeginEditing [_textStorage setFont:_font]; } + var currentAttributes = [_textStorage attributesAtIndex:range.location effectiveRange:nil] || _typingAttributes; + + [[[[self window] undoManager] prepareWithInvocationTarget:self] + setFont:[currentAttributes objectForKey:CPFontAttributeName] || _font + range:CPMakeRangeCopy(range)]; + [_textStorage addAttribute:CPFontAttributeName value:font range:CPMakeRangeCopy(range)]; [_layoutManager _validateLayoutAndGlyphs]; } @@ -1488,7 +1494,10 @@ var kDelegateRespondsTo_textShouldBeginEditing var currRange = CPMakeRange(_selectionRange.location, 0), oldFont, attributes, - scrollRange = CPMakeRange(CPMaxRange(_selectionRange), 0); + scrollRange = CPMakeRange(CPMaxRange(_selectionRange), 0), + undoManager = [[self window] undoManager]; + + [undoManager beginUndoGrouping]; if ([self isRichText]) { @@ -1518,6 +1527,8 @@ var kDelegateRespondsTo_textShouldBeginEditing scrollRange = CPMakeRange(length, 0); } + [undoManager endUndoGrouping]; + [_layoutManager _validateLayoutAndGlyphs]; [self sizeToFit]; [self setNeedsDisplay:YES];