From 83c336d7d606a8d2c6f50c403a7fecc770e20cbe Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Fri, 20 Dec 2024 20:01:59 +0100 Subject: [PATCH] Log when a derived gets cleared (#236739) --- src/vs/base/common/observableInternal/derived.ts | 1 + src/vs/base/common/observableInternal/logging.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/vs/base/common/observableInternal/derived.ts b/src/vs/base/common/observableInternal/derived.ts index 5421b023df9..54a1e99296d 100644 --- a/src/vs/base/common/observableInternal/derived.ts +++ b/src/vs/base/common/observableInternal/derived.ts @@ -220,6 +220,7 @@ export class Derived extends BaseObservable im */ this.state = DerivedState.initial; this.value = undefined; + getLogger()?.handleDerivedCleared(this); for (const d of this.dependencies) { d.removeObserver(this); } diff --git a/src/vs/base/common/observableInternal/logging.ts b/src/vs/base/common/observableInternal/logging.ts index 8dc526a45be..f0bc82170d8 100644 --- a/src/vs/base/common/observableInternal/logging.ts +++ b/src/vs/base/common/observableInternal/logging.ts @@ -48,6 +48,7 @@ export interface IObservableLogger { handleDerivedCreated(observable: Derived): void; handleDerivedRecomputed(observable: Derived, info: IChangeInformation): void; + handleDerivedCleared(observable: Derived): void; handleBeginTransaction(transaction: TransactionImpl): void; handleEndTransaction(): void; @@ -170,6 +171,15 @@ export class ConsoleObservableLogger implements IObservableLogger { changedObservables.clear(); } + handleDerivedCleared(derived: Derived): void { + if (!this._isIncluded(derived)) { return; } + + console.log(...this.textToConsoleArgs([ + formatKind('derived cleared'), + styled(derived.debugName, { color: 'BlueViolet' }), + ])); + } + handleFromEventObservableTriggered(observable: FromEventObservable, info: IChangeInformation): void { if (!this._isIncluded(observable)) { return; }