From edba006045ea2a9acf459385bae442ed0d5ad5d7 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 May 2022 12:32:06 -0700 Subject: [PATCH] Clear all decorations on reset --- src/browser/Terminal.ts | 1 + src/common/TestUtils.test.ts | 1 + src/common/services/DecorationService.ts | 7 +++++++ src/common/services/Services.ts | 1 + 4 files changed, 10 insertions(+) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 491a209e..a8accd78 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1358,6 +1358,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this._setup(); super.reset(); this._selectionService?.reset(); + this._decorationService.reset(); // reattach this._customKeyEventHandler = customKeyEventHandler; diff --git a/src/common/TestUtils.test.ts b/src/common/TestUtils.test.ts index 1ec5a05a..10b6b5ef 100644 --- a/src/common/TestUtils.test.ts +++ b/src/common/TestUtils.test.ts @@ -166,6 +166,7 @@ export class MockDecorationService implements IDecorationService { public onDecorationRegistered = new EventEmitter().event; public onDecorationRemoved = new EventEmitter().event; public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined { return undefined; } + public reset(): void { } public *getDecorationsOnLine(line: number): IterableIterator { } public dispose(): void { } } diff --git a/src/common/services/DecorationService.ts b/src/common/services/DecorationService.ts index 00ea3236..3c646501 100644 --- a/src/common/services/DecorationService.ts +++ b/src/common/services/DecorationService.ts @@ -49,6 +49,13 @@ export class DecorationService extends Disposable implements IDecorationService return decoration; } + public reset(): void { + for (let i = 0; i < this._decorations.length; i++) { + this._decorations[0].dispose(); + } + this._decorations.length = 0; + } + public *getDecorationsOnLine(line: number): IterableIterator { // TODO: This could be made much faster if _decorations was sorted by line (and col?) for (const d of this.decorations) { diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index e086ff56..c6d47816 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -308,6 +308,7 @@ export interface IDecorationService extends IDisposable { readonly onDecorationRegistered: IEvent; readonly onDecorationRemoved: IEvent; registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined; + reset(): void; /** Iterates over the decorations on a line (in no particular order). */ getDecorationsOnLine(line: number): IterableIterator; }