fix: prevent Delete key from corrupting quantity during ActionClone

ObservableList.Remove fired ItemRemoved even when the item wasn't in
the list, causing Plate to decrement Quantity.Nested for clone preview
parts that were never added — producing -1 counts. Delete in PlateView
now cancels ActionClone instead of trying to remove its preview parts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 21:34:25 -04:00
parent c5943e22eb
commit 7e86313d7c
2 changed files with 7 additions and 2 deletions

View File

@@ -46,7 +46,8 @@ namespace OpenNest.Collections
public bool Remove(T item)
{
var success = items.Remove(item);
ItemRemoved?.Invoke(this, new ItemRemovedEventArgs<T>(item, success));
if (success)
ItemRemoved?.Invoke(this, new ItemRemovedEventArgs<T>(item, success));
return success;
}

View File

@@ -386,7 +386,11 @@ namespace OpenNest.Controls
switch (e.KeyCode)
{
case Keys.Delete:
if (selectedCutOff != null)
if (currentAction is ActionClone)
{
SetAction(typeof(ActionSelect));
}
else if (selectedCutOff != null)
{
Plate.CutOffs.Remove(selectedCutOff);
selectedCutOff = null;