Skip to content

Commit

Permalink
Merge pull request #155 from invopop/marker_listeners
Browse files Browse the repository at this point in the history
Dispose marker listeners and only fetch current model problems
  • Loading branch information
beliolfa authored Sep 19, 2024
2 parents 6763968 + 958ca2a commit 8edb566
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib/editor/code/EditorCode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
export let hideConsoleBar = false;
let editorEl: HTMLElement;
let modelUri: Monaco.Uri;
let monacoEditor: Monaco.editor.IStandaloneCodeEditor;
let model: Monaco.editor.ITextModel;
let readOnlyEditHandler: Monaco.IDisposable;
let markerListener: Monaco.IDisposable;
let lineNumber = 1;
let column = 1;
let drawerClosed = false;
Expand Down Expand Up @@ -83,8 +85,7 @@
loader.config({ monaco: monacoEditorImport.default });
monaco = await loader.init();
let modelUri = monaco.Uri.parse(goblDocURL);
modelUri = monaco.Uri.parse(goblDocURL);
model = monaco.editor.createModel("", "json", modelUri);
setSchemaURI(jsonSchemaURL);
Expand Down Expand Up @@ -208,8 +209,9 @@
validateSchema(value);
});
monaco.editor.onDidChangeMarkers(() => {
problems.set(monaco.editor.getModelMarkers({}));
markerListener = monaco.editor.onDidChangeMarkers(() => {
const markers = monaco.editor.getModelMarkers({ resource: modelUri });
problems.set(markers);
});
monacoEditor.onDidChangeCursorPosition((event) => {
Expand All @@ -229,6 +231,10 @@
onDestroy(() => {
$problems = []; // reset problems
if (markerListener) {
markerListener.dispose();
}
if (unsubscribeEditor != null) {
unsubscribeEditor();
}
Expand Down

0 comments on commit 8edb566

Please sign in to comment.