Skip to content

Commit

Permalink
fix: dev-tools only set monaco model and text when changing (google#2417
Browse files Browse the repository at this point in the history
)

Context:
- mit-cml/workspace-multiselect#62 (comment)
- mit-cml/workspace-multiselect#62 (comment)
- mit-cml/workspace-multiselect#62 (comment)

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 <hollowman@opensuse.org>
  • Loading branch information
HollowMan6 authored Jul 19, 2024
1 parent e239987 commit 20be3a3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/dev-tools/src/playground/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ export function createPlayground(
wordWrap: true,
});
}
if (
generateModel.getValue() === text &&
editor.getModel() === generateModel
) {
return;
}
generateModel.pushEditOperations(
[],
[{range: generateModel.getFullModelRange(), text}],
Expand Down

0 comments on commit 20be3a3

Please sign in to comment.