From b3960f55d8ea8d5c0fa1d35c0fe4fbf65953762a Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Tue, 7 Jan 2025 23:08:22 -0600 Subject: [PATCH] 0832/rxFS: fix delete block, hide search block (#1854) - Delete blocks leave holes in the arrays, breaking other blocks - The search block has been broken this entire time (`.indexOf(...) == undefined` is always false). It's not clear what it's even supposed to do, so just hide it. --- extensions/0832/rxFS.js | 8 ++++++-- extensions/0832/rxFS2.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/extensions/0832/rxFS.js b/extensions/0832/rxFS.js index 4191496066..331cc5d18a 100644 --- a/extensions/0832/rxFS.js +++ b/extensions/0832/rxFS.js @@ -149,6 +149,7 @@ { blockIconURI: file, opcode: "search", + hideFromPalette: true, blockType: Scratch.BlockType.REPORTER, text: Scratch.translate("search [STR]"), arguments: { @@ -200,8 +201,11 @@ del({ STR }) { str = btoa(unescape(encodeURIComponent(STR))); - rxFSfi[rxFSsy.indexOf(str) + 1 - 1] = undefined; - rxFSsy[rxFSsy.indexOf(str) + 1 - 1] = undefined; + const index = rxFSsy.indexOf(str); + if (index !== -1) { + rxFSfi.splice(index, 1); + rxFSsy.splice(index, 1); + } } file({ STR, STR2 }) { diff --git a/extensions/0832/rxFS2.js b/extensions/0832/rxFS2.js index 4e631709b9..31fad1e381 100644 --- a/extensions/0832/rxFS2.js +++ b/extensions/0832/rxFS2.js @@ -180,6 +180,7 @@ { blockIconURI: folder, opcode: "search", + hideFromPalette: true, blockType: Scratch.BlockType.REPORTER, text: Scratch.translate({ id: "search", default: "search [STR]" }), arguments: { @@ -225,8 +226,11 @@ del({ STR }) { str = encodeURIComponent(STR); - rxFSfi[rxFSsy.indexOf(str) + 1 - 1] = undefined; - rxFSsy[rxFSsy.indexOf(str) + 1 - 1] = undefined; + const index = rxFSsy.indexOf(str); + if (index !== -1) { + rxFSfi.splice(index, 1); + rxFSsy.splice(index, 1); + } } folder({ STR, STR2 }) {