[ColorPicker] Prevent creation of duplicate colors in history (#10705)
If color already exists in history, move it to position 0. This prevents new duplicate colors, but ignores existing duplicates.
This commit is contained in:
parent
4dab056d28
commit
e53b4346d7
|
@ -133,7 +133,17 @@ namespace ColorPicker.ViewModels
|
|||
{
|
||||
ClipboardHelper.CopyToClipboard(ColorText);
|
||||
|
||||
_userSettings.ColorHistory.Insert(0, GetColorString());
|
||||
var color = GetColorString();
|
||||
|
||||
var oldIndex = _userSettings.ColorHistory.IndexOf(color);
|
||||
if (oldIndex != -1)
|
||||
{
|
||||
_userSettings.ColorHistory.Move(oldIndex, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_userSettings.ColorHistory.Insert(0, color);
|
||||
}
|
||||
|
||||
if (_userSettings.ColorHistory.Count > _userSettings.ColorHistoryLimit.Value)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue