From 1c4ca0c38c6ba6f45c418df8f5af07b016fc4b7c Mon Sep 17 00:00:00 2001 From: Jon Sequeira Date: Thu, 21 Dec 2023 10:05:19 -0800 Subject: [PATCH] try only parenting on same command type --- .../Commands/KernelCommand.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Microsoft.DotNet.Interactive/Commands/KernelCommand.cs b/src/Microsoft.DotNet.Interactive/Commands/KernelCommand.cs index b437b880fb..bfd567997b 100644 --- a/src/Microsoft.DotNet.Interactive/Commands/KernelCommand.cs +++ b/src/Microsoft.DotNet.Interactive/Commands/KernelCommand.cs @@ -35,6 +35,18 @@ public void SetParent(KernelCommand parent, bool bubbleEvents = false) throw new ArgumentNullException(nameof(parent)); } + if (_token is not null) + { + // FIX: (SetParent) + if (parent._token is null) + { + } + else if (GetRootToken(_token) != GetRootToken(parent._token)) + { + throw new InvalidOperationException("Parent cannot be changed."); + } + } + if (_parent is null) { _parent = parent;