diff --git a/src/browser/Decorations/BufferDecorationRenderer.ts b/src/browser/Decorations/BufferDecorationRenderer.ts index 74fc59a7..26166c77 100644 --- a/src/browser/Decorations/BufferDecorationRenderer.ts +++ b/src/browser/Decorations/BufferDecorationRenderer.ts @@ -63,6 +63,7 @@ export class BufferDecorationRenderer extends Disposable { let element = this._decorationElements.get(decoration); if (!element) { element = this._createElement(decoration); + decoration.onDispose(() => this._removeDecoration(decoration)); this._decorationElements.set(decoration, element); this._container.appendChild(element); } diff --git a/src/common/services/DecorationService.ts b/src/common/services/DecorationService.ts index f18ad9b5..d561e91b 100644 --- a/src/common/services/DecorationService.ts +++ b/src/common/services/DecorationService.ts @@ -65,6 +65,11 @@ class Decoration extends Disposable implements IInternalDecoration { ) { super(); this.marker = options.marker; - // TODO: Make sure dispose doesn't need to do anything else? + this.marker.onDispose(() => this.dispose()); + } + public override dispose(): void { + this.element?.remove(); + this._onDispose.fire(); + super.dispose(); } } diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index ee6a0cfa..a73cdc19 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -574,7 +574,7 @@ describe('API Integration Tests', function(): void { await page.evaluate(`window.term.scrollLines(10)`); await page.evaluate(`window.term.addMarker(3)`); await page.evaluate(`window.term.addMarker(4)`); - await page.evaluate(` + await page.evaluate(` for (let i = 0; i < window.term.markers.length; ++i) { const marker = window.term.markers[i]; marker.onDispose(() => window.disposeStack.push(marker));