fix(dock): improve drop mutation safety and tree cleanup

This commit is contained in:
2026-03-28 14:46:58 +09:00
parent c6a71e599b
commit 4aeaecfe81
3 changed files with 146 additions and 114 deletions

View File

@@ -67,9 +67,17 @@ public partial class DockGroupNode : DockNode
if (_children.Contains(node))
{
int oldIndex = _children.IndexOf(node);
if (oldIndex == index || oldIndex == index - 1) return;
if (oldIndex == index) return;
// If we're moving an item forward, the target index will shift after removal
int targetIndex = index;
if (targetIndex > oldIndex) targetIndex--;
if (oldIndex == targetIndex) return;
_children.RemoveAt(oldIndex);
if (index > oldIndex) index--;
_children.Insert(targetIndex, node);
return;
}
// Check for cycles