From 7ed79eb21c8c8987c11e49fd50c3be0c1d5e4673 Mon Sep 17 00:00:00 2001 From: la Date: Wed, 13 May 2026 21:04:00 +0300 Subject: [PATCH] fix: Fix bug when pasting mutatorarg blocks --- packages/blockly/blocks/procedures.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/blockly/blocks/procedures.ts b/packages/blockly/blocks/procedures.ts index 9493a2dc035..8af8825d251 100644 --- a/packages/blockly/blocks/procedures.ts +++ b/packages/blockly/blocks/procedures.ts @@ -712,14 +712,32 @@ const PROCEDURES_MUTATORARGUMENT = { sourceBlock.workspace; const blocks = workspace.getAllBlocks(false); const caselessName = varName.toLowerCase(); + const usedNames = []; + let isDuplicate = false; for (let i = 0; i < blocks.length; i++) { if (blocks[i].id === this.getSourceBlock()!.id) { continue; } // Other blocks values may not be set yet when this is loaded. const otherVar = blocks[i].getFieldValue('NAME'); - if (otherVar && otherVar.toLowerCase() === caselessName) { + if (otherVar) { + if (!this.editingInteractively) { + usedNames.push(otherVar); + } + if (otherVar.toLowerCase() === caselessName) { + isDuplicate = true; + } + } + } + + if (isDuplicate) { + if (this.editingInteractively) { return null; + } else { + varName = Variables.generateUniqueNameFromOptions( + Procedures.DEFAULT_ARG, + usedNames, + ); } }