Fixes #1398. Fixed with CPTokenField: deleting tokens in front of selected tokens would shift the selection to the right.

This commit is contained in:
Alexander Ljungberg
2011-11-16 12:04:03 +00:00
parent 072b43d178
commit e7d9b0503b
+7 -2
View File
@@ -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];