From 071775997a0af84ddba71b314bb6afd8f937c803 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 18:24:58 +0000 Subject: [PATCH 1/4] Initial plan From d4661c198b2be062e984a72ea67399a61aee4591 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 18:31:19 +0000 Subject: [PATCH 2/4] Add null checks for targetBlock() calls in procedures.js Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- blocks_vertical/procedures.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/blocks_vertical/procedures.js b/blocks_vertical/procedures.js index 1164ce76b7..d5e072f84f 100644 --- a/blocks_vertical/procedures.js +++ b/blocks_vertical/procedures.js @@ -623,13 +623,15 @@ Blockly.ScratchBlocks.ProcedureUtils.updateDeclarationProcCode_ = function() { this.procCode_ += input.fieldRow[0].getValue(); } else if (input.type == Blockly.INPUT_VALUE) { // Inspect the argument editor. - var target = input.connection.targetBlock(); - this.displayNames_.push(target.getFieldValue('TEXT')); - this.argumentIds_.push(input.name); - if (target.type == 'argument_editor_boolean') { - this.procCode_ += '%b'; - } else { - this.procCode_ += '%s'; + var target = input.connection && input.connection.targetBlock(); + if (target) { + this.displayNames_.push(target.getFieldValue('TEXT')); + this.argumentIds_.push(input.name); + if (target.type == 'argument_editor_boolean') { + this.procCode_ += '%b'; + } else { + this.procCode_ += '%s'; + } } } else { throw new Error( @@ -649,8 +651,10 @@ Blockly.ScratchBlocks.ProcedureUtils.focusLastEditor_ = function() { newInput.fieldRow[0].showEditor_(); } else if (newInput.type == Blockly.INPUT_VALUE) { // Inspect the argument editor. - var target = newInput.connection.targetBlock(); - target.getField('TEXT').showEditor_(); + var target = newInput.connection && newInput.connection.targetBlock(); + if (target) { + target.getField('TEXT').showEditor_(); + } } } }; @@ -737,7 +741,7 @@ Blockly.ScratchBlocks.ProcedureUtils.removeFieldCallback = function(field) { var input = this.inputList[n]; if (input.connection) { var target = input.connection.targetBlock(); - if (target.getField(field.name) == field) { + if (target && target.getField(field.name) == field) { inputNameToRemove = input.name; } } else { From 6b93d17787e046c25aec9a803aa1d66bbcd7e386 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 18:32:30 +0000 Subject: [PATCH 3/4] Use explicit null checks for better code clarity Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- blocks_vertical/procedures.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blocks_vertical/procedures.js b/blocks_vertical/procedures.js index d5e072f84f..d5fabec337 100644 --- a/blocks_vertical/procedures.js +++ b/blocks_vertical/procedures.js @@ -623,7 +623,7 @@ Blockly.ScratchBlocks.ProcedureUtils.updateDeclarationProcCode_ = function() { this.procCode_ += input.fieldRow[0].getValue(); } else if (input.type == Blockly.INPUT_VALUE) { // Inspect the argument editor. - var target = input.connection && input.connection.targetBlock(); + var target = input.connection ? input.connection.targetBlock() : null; if (target) { this.displayNames_.push(target.getFieldValue('TEXT')); this.argumentIds_.push(input.name); @@ -651,7 +651,7 @@ Blockly.ScratchBlocks.ProcedureUtils.focusLastEditor_ = function() { newInput.fieldRow[0].showEditor_(); } else if (newInput.type == Blockly.INPUT_VALUE) { // Inspect the argument editor. - var target = newInput.connection && newInput.connection.targetBlock(); + var target = newInput.connection ? newInput.connection.targetBlock() : null; if (target) { target.getField('TEXT').showEditor_(); } From c3fac31d4c0b0b147a3b5fc430f02916347d4f1a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:06:20 +0000 Subject: [PATCH 4/4] Add getText() method to field_customInput to fix XML serialization error Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- core/field_customInput.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/field_customInput.js b/core/field_customInput.js index acf0a49a7c..638034e3f8 100644 --- a/core/field_customInput.js +++ b/core/field_customInput.js @@ -159,6 +159,18 @@ Blockly.FieldCustom.prototype.getValue = function() { return this.value_; }; +/** + * Get the text from this field for display and XML serialization. + * Return empty string since the actual code is stored in value_ and + * should not be serialized as display text. + * @return {string} Empty string for display. + */ +Blockly.FieldCustom.prototype.getText = function() { + // Return empty string to avoid serializing code with special characters + // The actual value is handled separately via getValue/setValue + return ''; +}; + /** * do whatever the user desires on-edit * @private