From 20be3a3b43af41987f631b931d65121d761f6377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=84=8D=F0=9D=95=A0=F0=9D=95=9D=F0=9D=95=9D=F0=9D=95=A0?= =?UTF-8?q?=F0=9D=95=A8=20=F0=9D=95=84=F0=9D=95=92=F0=9D=95=9F?= Date: Fri, 19 Jul 2024 13:32:21 +0300 Subject: [PATCH] fix: dev-tools only set monaco model and text when changing (#2417) Context: - https://github.com/mit-cml/workspace-multiselect/pull/62#issuecomment-2196819235 - https://github.com/mit-cml/workspace-multiselect/pull/62#issuecomment-2212561339 - https://github.com/mit-cml/workspace-multiselect/pull/62#issuecomment-2214203536 In multi-select plugin, a significant amount of workspace change events (for each block) can be triggered at the same time, which causes the garbage collection mechanism to fail, so that we eventually have JS heap overflow and the page crashed in Chromium. This commit introduces a workaround for this, so that we only update the page when we have model or text updates in monaco. Signed-off-by: Hollow Man --- plugins/dev-tools/src/playground/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/dev-tools/src/playground/index.js b/plugins/dev-tools/src/playground/index.js index 28e0852780..c0f8001ee4 100644 --- a/plugins/dev-tools/src/playground/index.js +++ b/plugins/dev-tools/src/playground/index.js @@ -175,6 +175,12 @@ export function createPlayground( wordWrap: true, }); } + if ( + generateModel.getValue() === text && + editor.getModel() === generateModel + ) { + return; + } generateModel.pushEditOperations( [], [{range: generateModel.getFullModelRange(), text}],