From 18d83b8c501ce8eaa38f2d26eea0ff1345fc9475 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Mon, 20 Oct 2014 18:51:26 +0200 Subject: [PATCH] fix range exception when smart-cutting last word --- AppKit/CPTextView/CPTextView.j | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index e160ce85d..2b5dd04d7 100755 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1228,6 +1228,8 @@ var kDelegateRespondsTo_textShouldBeginEditing if (![self shouldChangeTextInRange:changedRange replacementString:@""]) return; + changedRange = CPIntersectionRange(CPMakeRange(0, [_layoutManager numberOfCharacters]), changedRange); + [[[[self window] undoManager] prepareWithInvocationTarget:self] _replaceCharactersInRange:CPMakeRange(_selectionRange.location, 0) withAttributedString:[_textStorage attributedSubstringFromRange:CPMakeRangeCopy(changedRange)]]; [_textStorage deleteCharactersInRange:CPMakeRangeCopy(changedRange)];