diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 2b5dd04d7..b2f646611 100755 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -429,6 +429,10 @@ var kDelegateRespondsTo_textShouldBeginEditing - (void)_replaceCharactersInRange:aRange withAttributedString:(CPString)aString { + [[[[self window] undoManager] prepareWithInvocationTarget:self] + _replaceCharactersInRange:CPMakeRange(aRange.location, [aString length]) + withAttributedString:[_textStorage attributedSubstringFromRange:CPMakeRangeCopy(aRange)]]; + [_textStorage replaceCharactersInRange:aRange withAttributedString:aString]; [self setSelectedRange:CPMakeRange(aRange.location, [aString length])]; [_layoutManager _validateLayoutAndGlyphs]; @@ -439,6 +443,10 @@ var kDelegateRespondsTo_textShouldBeginEditing } - (void)_replaceCharactersInRange:(CPRange)aRange withString:(CPString)aString { + [[[[self window] undoManager] prepareWithInvocationTarget:self] + _replaceCharactersInRange:CPMakeRange(aRange.location, [aString length]) + withString:[[self string] substringWithRange:CPMakeRangeCopy(aRange)]]; + [_textStorage replaceCharactersInRange:CPMakeRangeCopy(aRange) withString:aString]; [self setSelectedRange:CPMakeRange(aRange.location, aString.length)]; [_layoutManager _validateLayoutAndGlyphs];