Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat(domain): throw error when attempting to detach an already detached container

Lars Bergeree008d4af85c
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs
index ccf60cc8..2726fc9a 100644
--- a/GlazeWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs
+++ b/GlazeWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs
@@ -1,4 +1,5 @@
-using GlazeWM.Domain.Containers.Commands;
+using System;
+using GlazeWM.Domain.Containers.Commands;
using GlazeWM.Domain.Workspaces;
using GlazeWM.Infrastructure.Bussing;
@@ -20,6 +21,9 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
var childToRemove = command.ChildToRemove;
var parent = childToRemove.Parent;
+ if (parent == null)
+ throw new Exception("Attempting to detach an already detached container. This is a bug.");
+
childToRemove.Parent = null;
parent.Children.Remove(childToRemove);
parent.ChildFocusOrder.Remove(childToRemove);