From 43a014e8c1e178c5647fa467363e6ac64e6ad8cb Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 21 Mar 2022 16:57:49 -0700 Subject: [PATCH] Fix decoration lifecycle issues --- src/common/services/DecorationService.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/services/DecorationService.ts b/src/common/services/DecorationService.ts index 6c750236..fba5fc35 100644 --- a/src/common/services/DecorationService.ts +++ b/src/common/services/DecorationService.ts @@ -32,7 +32,10 @@ export class DecorationService extends Disposable implements IDecorationService if (decoration) { decoration.onDispose(() => { if (decoration) { - this._decorations.splice(this._decorations.indexOf(decoration), 1); + const index = this._decorations.indexOf(decoration); + if (index >= 0) { + this._decorations.splice(this._decorations.indexOf(decoration), 1); + } } }); this._decorations.push(decoration); @@ -70,6 +73,10 @@ class Decoration extends Disposable implements IInternalDecoration { } } public override dispose(): void { + if (this._isDisposed) { + return; + } + this._isDisposed = true; this._onDispose.fire(); super.dispose(); }