From 5cc310c11bec90316652e6957be64d0d3c54ca30 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Mon, 5 Aug 2024 16:21:07 -0700 Subject: [PATCH] Fix a few double disposable registrations (#224895) These values are being registered on a disposable store more than once. I think some of the instances in tests are actually leaking the `MutableObservableValue` too since it's not registered --- .../contrib/preferences/browser/preferencesWidgets.ts | 3 +-- .../contrib/testing/browser/testingOutputPeek.ts | 8 ++++---- src/vs/workbench/contrib/testing/common/testExclusions.ts | 4 ++-- .../workbench/contrib/testing/common/testServiceImpl.ts | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts index 0e9c2437930..cac09b8c128 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts @@ -437,8 +437,7 @@ export class SearchWidget extends Widget { protected createInputBox(parent: HTMLElement): HistoryInputBox { const showHistoryHint = () => showHistoryKeybindingHint(this.keybindingService); - const box = this._register(new ContextScopedHistoryInputBox(parent, this.contextViewService, { ...this.options, showHistoryHint }, this.contextKeyService)); - return box; + return new ContextScopedHistoryInputBox(parent, this.contextViewService, { ...this.options, showHistoryHint }, this.contextKeyService); } showMessage(message: string): void { diff --git a/src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts b/src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts index ad9e402a89b..5ac7eb965bc 100644 --- a/src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts +++ b/src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts @@ -92,18 +92,18 @@ export class TestingPeekOpener extends Disposable implements ITestingPeekOpener private lastUri?: TestUriWithDocument; /** @inheritdoc */ - public readonly historyVisible = MutableObservableValue.stored(this._register(new StoredValue({ + public readonly historyVisible = this._register(MutableObservableValue.stored(new StoredValue({ key: 'testHistoryVisibleInPeek', scope: StorageScope.PROFILE, target: StorageTarget.USER, - }, this.storageService)), false); + }, this.storageService), false)); /** @inheritdoc */ - public readonly callStackVisible = MutableObservableValue.stored(this._register(new StoredValue({ + public readonly callStackVisible = this._register(MutableObservableValue.stored(new StoredValue({ key: 'testCallStackVisible', scope: StorageScope.PROFILE, target: StorageTarget.USER, - }, this.storageService)), true); + }, this.storageService), true)); constructor( @IConfigurationService private readonly configuration: IConfigurationService, diff --git a/src/vs/workbench/contrib/testing/common/testExclusions.ts b/src/vs/workbench/contrib/testing/common/testExclusions.ts index 768e931f314..65ff6ccf0bc 100644 --- a/src/vs/workbench/contrib/testing/common/testExclusions.ts +++ b/src/vs/workbench/contrib/testing/common/testExclusions.ts @@ -13,7 +13,7 @@ import { InternalTestItem } from 'vs/workbench/contrib/testing/common/testTypes' export class TestExclusions extends Disposable { private readonly excluded = this._register( - MutableObservableValue.stored(this._register(new StoredValue>({ + MutableObservableValue.stored(new StoredValue>({ key: 'excludedTestItems', scope: StorageScope.WORKSPACE, target: StorageTarget.MACHINE, @@ -21,7 +21,7 @@ export class TestExclusions extends Disposable { deserialize: v => new Set(JSON.parse(v)), serialize: v => JSON.stringify([...v]) }, - }, this.storageService)), new Set()) + }, this.storageService), new Set()) ); constructor(@IStorageService private readonly storageService: IStorageService) { diff --git a/src/vs/workbench/contrib/testing/common/testServiceImpl.ts b/src/vs/workbench/contrib/testing/common/testServiceImpl.ts index a4c2cc9b658..786d3d292cd 100644 --- a/src/vs/workbench/contrib/testing/common/testServiceImpl.ts +++ b/src/vs/workbench/contrib/testing/common/testServiceImpl.ts @@ -82,11 +82,11 @@ export class TestService extends Disposable implements ITestService { /** * @inheritdoc */ - public readonly showInlineOutput = MutableObservableValue.stored(this._register(new StoredValue({ + public readonly showInlineOutput = this._register(MutableObservableValue.stored(new StoredValue({ key: 'inlineTestOutputVisible', scope: StorageScope.WORKSPACE, target: StorageTarget.USER - }, this.storage)), true); + }, this.storage), true)); constructor( @IContextKeyService contextKeyService: IContextKeyService,