Fixed: smart copy/paste cycle was leaving an additional whitespace on the LHS (#2776)

This commit is contained in:
daboe01
2019-06-13 16:17:52 +02:00
committed by Martin Carlberg
parent 47ab94b5bc
commit 1a7ced34a7
+12 -4
View File
@@ -467,12 +467,20 @@ var kDelegateRespondsTo_textShouldBeginEditing
var shouldUseSmartPasting = [self _shouldUseSmartPasting];
if (shouldUseSmartPasting && _selectionRange.location > 0)
if (shouldUseSmartPasting)
{
if (!_isWhitespaceCharacter([[_textStorage string] characterAtIndex:_selectionRange.location - 1]) &&
_selectionRange.location != [_layoutManager numberOfCharacters])
if (_isWhitespaceCharacter([[stringForPasting string] characterAtIndex:0]))
{
[self insertText:" "];
if (_selectionRange.location == 0 ||
_isWhitespaceCharacter([[_textStorage string] characterAtIndex:_selectionRange.location - 1]) &&
_selectionRange.location != [_layoutManager numberOfCharacters])
[stringForPasting deleteCharactersInRange:CPMakeRange(0, 1)];
}
else
{
if (_selectionRange.location > 0 &
!_isWhitespaceCharacter([[_textStorage string] characterAtIndex:_selectionRange.location - 1]))
[self insertText:" "];
}
}