mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01:00
[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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user