From 605eaa1adbd6cc42095263f5ff8c8fde0598de02 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 11 Oct 2024 14:31:29 -0700 Subject: [PATCH] fix: Fix exception when disposing of a workspace with a variable block obscuring a shadow block. --- core/workspace.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/workspace.ts b/core/workspace.ts index 9e7d7c88432..36ce720b8c0 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -371,7 +371,14 @@ export class Workspace implements IASTNodeLocation { this.topComments[this.topComments.length - 1].dispose(); } eventUtils.setGroup(existingGroup); - this.variableMap.clear(); + // If this is a flyout workspace, its variable map is shared with the + // parent workspace, so we either don't want to disturb it if we're just + // disposing the flyout, or if the flyout is being disposed because the + // main workspace is being disposed, then the main workspace will handle + // cleaning it up. + if (!this.isFlyout) { + this.variableMap.clear(); + } if (this.potentialVariableMap) { this.potentialVariableMap.clear(); }