Skip to content

Commit effcbdd

Browse files
committed
Fixes microsoft/monaco-editor#672: Better disposing
1 parent 017dfed commit effcbdd

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/vs/base/browser/ui/contextview/contextview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export class ContextView {
128128

129129
public setContainer(container: HTMLElement): void {
130130
if (this.$container) {
131+
this.$container.getHTMLElement().removeChild(this.$view.getHTMLElement());
131132
this.$container.off(ContextView.BUBBLE_UP_EVENTS);
132133
this.$container.off(ContextView.BUBBLE_DOWN_EVENTS, true);
133134
this.$container = null;

src/vs/editor/browser/widget/diffEditorWidget.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
209209

210210
this._editorWorkerService = editorWorkerService;
211211
this._codeEditorService = codeEditorService;
212-
this._contextKeyService = contextKeyService.createScoped(domElement);
212+
this._contextKeyService = this._register(contextKeyService.createScoped(domElement));
213213
this._contextKeyService.createKey('isInDiffEditor', true);
214214
this._themeService = themeService;
215215
this._notificationService = notificationService;
@@ -313,14 +313,14 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
313313
this._setStrategy(new DiffEdtorWidgetInline(this._createDataSource(), this._enableSplitViewResizing));
314314
}
315315

316-
this._codeEditorService.addDiffEditor(this);
317-
318316
this._register(themeService.onThemeChange(t => {
319317
if (this._strategy && this._strategy.applyColors(t)) {
320318
this._updateDecorationsRunner.schedule();
321319
}
322320
this._containerDomElement.className = DiffEditorWidget._getClassName(this._themeService.getTheme(), this._renderSideBySide);
323321
}));
322+
323+
this._codeEditorService.addDiffEditor(this);
324324
}
325325

326326
public get ignoreTrimWhitespace(): boolean {
@@ -465,20 +465,37 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
465465
public dispose(): void {
466466
this._codeEditorService.removeDiffEditor(this);
467467

468+
if (this._beginUpdateDecorationsTimeout !== -1) {
469+
window.clearTimeout(this._beginUpdateDecorationsTimeout);
470+
this._beginUpdateDecorationsTimeout = -1;
471+
}
472+
468473
window.clearInterval(this._measureDomElementToken);
469474

470475
this._cleanViewZonesAndDecorations();
471476

477+
this._overviewDomElement.removeChild(this._originalOverviewRuler.getDomNode());
472478
this._originalOverviewRuler.dispose();
479+
this._overviewDomElement.removeChild(this._modifiedOverviewRuler.getDomNode());
473480
this._modifiedOverviewRuler.dispose();
481+
this._overviewDomElement.removeChild(this._overviewViewportDomElement.domNode);
482+
this._containerDomElement.removeChild(this._overviewDomElement);
474483

484+
this._containerDomElement.removeChild(this._originalDomNode);
475485
this.originalEditor.dispose();
486+
487+
this._containerDomElement.removeChild(this._modifiedDomNode);
476488
this.modifiedEditor.dispose();
477489

478490
this._strategy.dispose();
479491

492+
this._containerDomElement.removeChild(this._reviewPane.domNode.domNode);
493+
this._containerDomElement.removeChild(this._reviewPane.shadow.domNode);
494+
this._containerDomElement.removeChild(this._reviewPane.actionBarContainer.domNode);
480495
this._reviewPane.dispose();
481496

497+
this._domElement.removeChild(this._containerDomElement);
498+
482499
this._onDidDispose.fire();
483500

484501
super.dispose();

src/vs/editor/contrib/parameterHints/parameterHintsWidget.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ export class ParameterHintsWidget implements IContentWidget, IDisposable {
498498

499499
dispose(): void {
500500
this.disposables = dispose(this.disposables);
501+
this.model.dispose();
501502
this.model = null;
502503
}
503504
}

0 commit comments

Comments
 (0)