From e8497bb0cceb810c2f09a162d7e2bada9f541196 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Wed, 25 Feb 2015 20:20:48 +0100 Subject: [PATCH] typing attributes fix --- AppKit/CPTextView/CPTextView.j | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index fcf6a8767..cc4d0b932 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -659,7 +659,6 @@ var kDelegateRespondsTo_textShouldBeginEditing - (void)setSelectedRange:(CPRange)range { [self setSelectedRange:range affinity:0 stillSelecting:NO]; - [self setTypingAttributes:[_textStorage attributesAtIndex:MAX(0, range.location -1) effectiveRange:nil]]; } - (void)setSelectedRange:(CPRange)range affinity:(CPSelectionAffinity /* unused */ )affinity stillSelecting:(BOOL)selecting @@ -688,7 +687,12 @@ var kDelegateRespondsTo_textShouldBeginEditing if (_isFirstResponder) [self updateInsertionPointStateAndRestartTimer:((_selectionRange.length === 0) && ![_caretTimer isValid])]; - [self setTypingAttributes:[_textStorage attributesAtIndex:MAX(0, range.location -1) effectiveRange:nil]]; + var peekLoc = MAX(0, range.location - 1); + + if ((_isNewlineCharacter([[_textStorage string] characterAtIndex:peekLoc]))) + peekLoc++; + + [self setTypingAttributes:[_textStorage attributesAtIndex:peekLoc effectiveRange:nil]]; [[CPNotificationCenter defaultCenter] postNotificationName:CPTextViewDidChangeSelectionNotification object:self]; }