From 7f63be2cd292b5efe73e3893f2f4f910c18c8e0f Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Wed, 13 Aug 2014 19:56:50 -0400 Subject: [PATCH] Formatting: Make if statement more readable The if statement had a lot of sub-clauses. These were factored out into variable assignments. --- AppKit/CPTextView/CPTextView.j | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 794cd9e29..6615b96f2 100755 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1211,10 +1211,15 @@ var kDelegateRespondsTo_textShouldBeginEditing else changedRange = _selectionRange; - if (_previousSelectionGranularity > 0 && - changedRange.location > 0 && [self _isCharacterAtIndex:(changedRange.location - 1) granularity:_previousSelectionGranularity] && - changedRange.location < [[self string] length] && [self _isCharacterAtIndex:CPMaxRange(changedRange) granularity:_previousSelectionGranularity]) + var isCharacterAtLocationIndex = [self _isCharacterAtIndex:(changedRange.location - 1) granularity:_previousSelectionGranularity], + isCharacterAtMaxIndex = [self _isCharacterAtIndex:CPMaxRange(changedRange) granularity:_previousSelectionGranularity], + stringLength = [[self string] length]; + + if ((_previousSelectionGranularity > 0) && (changedRange.location > 0) && isCharacterAtLocationIndex && + (changedRange.location < stringLength) && isCharacterAtMaxIndex) + { changedRange.length++; + } [self _deleteForRange:changedRange]; }