From e7d9b0503bf64c1265fd907e8dd4de91e3147278 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Wed, 16 Nov 2011 12:04:03 +0000 Subject: [PATCH] Fixes #1398. Fixed with CPTokenField: deleting tokens in front of selected tokens would shift the selection to the right. --- AppKit/CPTokenField.j | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index efa88f8af..abf0081bc 100755 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -270,8 +270,13 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting", var indexOfToken = [[self _tokens] indexOfObject:token], objectValue = [self objectValue]; - // If the token was selected, deselect it for selection preservation. - [self _deselectToken:token]; + // If the selection was to the right of the deleted token, move it to the left. If the deleted token was + // selected, deselect it. + if (indexOfToken < _selectedRange.location) + _selectedRange.location--; + else + [self _deselectToken:token]; + // Preserve selection. var selection = CPCopyRange(_selectedRange); [objectValue removeObjectAtIndex:indexOfToken];