From e9efe5bbb7cfa9b8eb42ad61bd8cc961264ce4fe Mon Sep 17 00:00:00 2001 From: daboe01 Date: Sat, 21 Feb 2015 20:01:53 +0100 Subject: [PATCH] fix cornercases --- AppKit/CPTextView/CPTextView.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 65d6eff02..b711947aa 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1658,7 +1658,7 @@ var kDelegateRespondsTo_textShouldBeginEditing return _MakeRangeFromAbs(wordRange.location, MIN(MAX(0, numberOfCharacters - 1), searchIndex)); } // -> extend to the left - for (var searchIndex = index - 1; searchIndex > 0 && regex.exec(_characterTripletFromStringAtIndex(string, searchIndex)) === null; searchIndex--) + for (var searchIndex = index - 1; searchIndex >= 0 && regex.exec(_characterTripletFromStringAtIndex(string, searchIndex)) === null; searchIndex--) { wordRange.location = searchIndex; } @@ -1668,7 +1668,7 @@ var kDelegateRespondsTo_textShouldBeginEditing { index++; } - return _MakeRangeFromAbs(wordRange.location, MIN(MAX(0, numberOfCharacters - 1), index)); + return _MakeRangeFromAbs(wordRange.location, MIN(MAX(0, numberOfCharacters), index)); } - (CPRange)selectionRangeForProposedRange:(CPRange)proposedRange granularity:(CPSelectionGranularity)granularity