Skip to content

Commit f6731eb

Browse files
committed
slintpad: Properly dispose of editors and related data
This makes sure we send content invalidation when closing editors (by opening a new project).
1 parent 875ca07 commit f6731eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/slintpad/src/editor_widget.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ function tabTitleFromURL(url: monaco.Uri | undefined): string {
293293

294294
class EditorPaneWidget extends Widget {
295295
#editor: monaco.editor.IStandaloneCodeEditor;
296+
#model_ref: IRefernece<ITextEditorModel>;
296297

297298
static createNode(): HTMLElement {
298299
const node = document.createElement("div");
@@ -307,6 +308,8 @@ class EditorPaneWidget extends Widget {
307308

308309
super({ node: node });
309310

311+
this.#model_ref = model_ref;
312+
310313
this.id = model_ref.object.textEditorModel?.uri.toString() ?? "";
311314

312315
this.#editor = monaco.editor.create(this.contentNode, {
@@ -329,7 +332,8 @@ class EditorPaneWidget extends Widget {
329332

330333
dispose() {
331334
this.#editor.dispose();
332-
this.dispose();
335+
this.#model_ref.dispose();
336+
super.dispose();
333337
}
334338

335339
protected get contentNode(): HTMLDivElement {
@@ -420,7 +424,7 @@ export class EditorWidget extends Widget {
420424
this.#url_mapper = null;
421425

422426
if (this.#tab_panel !== null) {
423-
this.#layout.removeWidget(this.#tab_panel);
427+
this.#tab_panel.dispose();
424428
}
425429
this.#tab_panel = new TabPanel({ addButtonEnabled: false });
426430
this.#layout.addWidget(this.#tab_panel);

0 commit comments

Comments
 (0)