diff --git a/src/vs/editor/browser/widget/diffEditor/diffProviderFactoryService.ts b/src/vs/editor/browser/widget/diffEditor/diffProviderFactoryService.ts index 78d6e9b37b7..db160425769 100644 --- a/src/vs/editor/browser/widget/diffEditor/diffProviderFactoryService.ts +++ b/src/vs/editor/browser/widget/diffEditor/diffProviderFactoryService.ts @@ -60,6 +60,7 @@ export class WorkerBasedDocumentDiffProvider implements IDocumentDiffProvider, I public dispose(): void { this.diffAlgorithmOnDidChangeSubscription?.dispose(); + this.onDidChangeEventEmitter.dispose(); } async computeDiff(original: ITextModel, modified: ITextModel, options: IDocumentDiffProviderOptions, cancellationToken: CancellationToken): Promise { diff --git a/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts b/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts index 5a5bf23050a..445b09c7b2e 100644 --- a/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts +++ b/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts @@ -55,7 +55,7 @@ export class BracketPairsTree extends Disposable { private readonly getLanguageConfiguration: (languageId: string) => ResolvedLanguageConfiguration ) { super(); - this.didChangeEmitter = new Emitter(); + this.didChangeEmitter = this._register(new Emitter()); this.denseKeyProvider = new DenseKeyProvider(); this.brackets = new LanguageAgnosticBracketTokens(this.denseKeyProvider, this.getLanguageConfiguration); this.onDidChange = this.didChangeEmitter.event; diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index ede464c5a82..ebd3eccec51 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -299,7 +299,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati private readonly _guidesTextModelPart: GuidesTextModelPart; public get guides(): IGuidesTextModelPart { return this._guidesTextModelPart; } - private readonly _attachedViews = new AttachedViews(); + private readonly _attachedViews = this._register(new AttachedViews()); private readonly _viewModels = new Set(); constructor( diff --git a/src/vs/editor/common/model/tokens/abstractSyntaxTokenBackend.ts b/src/vs/editor/common/model/tokens/abstractSyntaxTokenBackend.ts index 2daa1d88fc6..344b2334f19 100644 --- a/src/vs/editor/common/model/tokens/abstractSyntaxTokenBackend.ts +++ b/src/vs/editor/common/model/tokens/abstractSyntaxTokenBackend.ts @@ -6,7 +6,7 @@ import { equals } from '../../../../base/common/arrays.js'; import { RunOnceScheduler } from '../../../../base/common/async.js'; import { Emitter, Event } from '../../../../base/common/event.js'; -import { Disposable } from '../../../../base/common/lifecycle.js'; +import { Disposable, IDisposable } from '../../../../base/common/lifecycle.js'; import { LineRange } from '../../core/ranges/lineRange.js'; import { StandardTokenType } from '../../encodedTokenAttributes.js'; import { ILanguageIdCodec } from '../../languages.js'; @@ -21,7 +21,7 @@ import { equalsIfDefinedC, thisEqualsC, arrayEqualsC } from '../../../../base/co /** * @internal */ -export class AttachedViews { +export class AttachedViews implements IDisposable { private readonly _onDidChangeVisibleRanges = new Emitter<{ view: IAttachedView; state: AttachedViewState | undefined }>(); public readonly onDidChangeVisibleRanges = this._onDidChangeVisibleRanges.event; @@ -57,6 +57,10 @@ export class AttachedViews { this._onDidChangeVisibleRanges.fire({ view, state: undefined }); this._viewsChanged.trigger(undefined); } + + public dispose(): void { + this._onDidChangeVisibleRanges.dispose(); + } } /** diff --git a/src/vs/editor/common/viewModel/minimapTokensColorTracker.ts b/src/vs/editor/common/viewModel/minimapTokensColorTracker.ts index 7fe9093e983..0247519b550 100644 --- a/src/vs/editor/common/viewModel/minimapTokensColorTracker.ts +++ b/src/vs/editor/common/viewModel/minimapTokensColorTracker.ts @@ -21,7 +21,7 @@ export class MinimapTokensColorTracker extends Disposable { private _colors!: RGBA8[]; private _backgroundIsLight!: boolean; - private readonly _onDidChange = new Emitter(); + private readonly _onDidChange = this._register(new Emitter()); public readonly onDidChange: Event = this._onDidChange.event; private constructor() { diff --git a/src/vs/editor/contrib/codelens/browser/codelensController.ts b/src/vs/editor/contrib/codelens/browser/codelensController.ts index 3a3877a2664..861a14a9ad7 100644 --- a/src/vs/editor/contrib/codelens/browser/codelensController.ts +++ b/src/vs/editor/contrib/codelens/browser/codelensController.ts @@ -76,6 +76,7 @@ export class CodeLensContribution implements IEditorContribution { this._localDispose(); this._localToDispose.dispose(); this._disposables.dispose(); + this._resolveCodeLensesScheduler.dispose(); this._oldCodeLensModels.dispose(); this._currentCodeLensModel?.dispose(); } diff --git a/src/vs/editor/contrib/find/browser/findController.ts b/src/vs/editor/contrib/find/browser/findController.ts index 6459340af24..ec2ee490e19 100644 --- a/src/vs/editor/contrib/find/browser/findController.ts +++ b/src/vs/editor/contrib/find/browser/findController.ts @@ -131,7 +131,7 @@ export class CommonFindController extends Disposable implements IEditorContribut this._notificationService = notificationService; this._hoverService = hoverService; - this._updateHistoryDelayer = new Delayer(500); + this._updateHistoryDelayer = this._register(new Delayer(500)); this._state = this._register(new FindReplaceState()); this.loadQueryState(); this._register(this._state.onFindReplaceStateChange((e) => this._onStateChanged(e))); diff --git a/src/vs/editor/contrib/folding/browser/foldingModel.ts b/src/vs/editor/contrib/folding/browser/foldingModel.ts index c7721163695..8e07ac5fe5e 100644 --- a/src/vs/editor/contrib/folding/browser/foldingModel.ts +++ b/src/vs/editor/contrib/folding/browser/foldingModel.ts @@ -8,6 +8,7 @@ import { IModelDecorationOptions, IModelDecorationsChangeAccessor, IModelDeltaDe import { FoldingRegion, FoldingRegions, ILineRange, FoldRange, FoldSource } from './foldingRanges.js'; import { hash } from '../../../../base/common/hash.js'; import { SelectedLines } from './folding.js'; +import { IDisposable } from '../../../../base/common/lifecycle.js'; export interface IDecorationProvider { getDecorationOption(isCollapsed: boolean, isHidden: boolean, isManual: boolean): IModelDecorationOptions; @@ -28,7 +29,7 @@ interface ILineMemento extends ILineRange { export type CollapseMemento = ILineMemento[]; -export class FoldingModel { +export class FoldingModel implements IDisposable { private readonly _textModel: ITextModel; private readonly _decorationProvider: IDecorationProvider; @@ -229,6 +230,7 @@ export class FoldingModel { public dispose() { this._decorationProvider.removeDecorations(this._editorDecorationIds); + this._updateEventEmitter.dispose(); } getAllRegionsAtLine(lineNumber: number, filter?: (r: FoldingRegion, level: number) => boolean): FoldingRegion[] { diff --git a/src/vs/editor/contrib/folding/browser/hiddenRangeModel.ts b/src/vs/editor/contrib/folding/browser/hiddenRangeModel.ts index f7927e0877b..1530d3405f3 100644 --- a/src/vs/editor/contrib/folding/browser/hiddenRangeModel.ts +++ b/src/vs/editor/contrib/folding/browser/hiddenRangeModel.ts @@ -13,7 +13,7 @@ import { IModelContentChangedEvent } from '../../../common/textModelEvents.js'; import { countEOL } from '../../../common/core/misc/eolCounter.js'; import { FoldingModel } from './foldingModel.js'; -export class HiddenRangeModel { +export class HiddenRangeModel implements IDisposable { private readonly _foldingModel: FoldingModel; private _hiddenRanges: IRange[]; @@ -134,6 +134,7 @@ export class HiddenRangeModel { this._foldingModelListener.dispose(); this._foldingModelListener = null; } + this._updateEventEmitter.dispose(); } } diff --git a/src/vs/editor/contrib/gotoError/browser/gotoErrorWidget.ts b/src/vs/editor/contrib/gotoError/browser/gotoErrorWidget.ts index b8394a1e72c..1fad47c247c 100644 --- a/src/vs/editor/contrib/gotoError/browser/gotoErrorWidget.ts +++ b/src/vs/editor/contrib/gotoError/browser/gotoErrorWidget.ts @@ -294,6 +294,7 @@ export class MarkerNavigationWidget extends PeekViewWidget { override dispose(): void { this._callOnDispose.dispose(); + this._onDidSelectRelatedInformation.dispose(); super.dispose(); } diff --git a/src/vs/editor/contrib/gotoSymbol/browser/peek/referencesWidget.ts b/src/vs/editor/contrib/gotoSymbol/browser/peek/referencesWidget.ts index f7330a59080..c6b40951477 100644 --- a/src/vs/editor/contrib/gotoSymbol/browser/peek/referencesWidget.ts +++ b/src/vs/editor/contrib/gotoSymbol/browser/peek/referencesWidget.ts @@ -248,7 +248,7 @@ export class ReferenceWidget extends peekView.PeekViewWidget { private readonly _disposeOnNewModel = new DisposableStore(); private readonly _callOnDispose = new DisposableStore(); - private readonly _onDidSelectReference = new Emitter(); + private readonly _onDidSelectReference = this._callOnDispose.add(new Emitter()); readonly onDidSelectReference = this._onDidSelectReference.event; private _tree!: ReferencesTree; diff --git a/src/vs/editor/contrib/parameterHints/browser/parameterHintsModel.ts b/src/vs/editor/contrib/parameterHints/browser/parameterHintsModel.ts index 0c07303dc17..c7bf621e8c2 100644 --- a/src/vs/editor/contrib/parameterHints/browser/parameterHintsModel.ts +++ b/src/vs/editor/contrib/parameterHints/browser/parameterHintsModel.ts @@ -78,7 +78,7 @@ export class ParameterHintsModel extends Disposable { this.editor = editor; this.providers = providers; - this.throttledDelayer = new Delayer(delay); + this.throttledDelayer = this._register(new Delayer(delay)); this._register(this.editor.onDidBlurEditorWidget(() => this.cancel())); this._register(this.editor.onDidChangeConfiguration(() => this.onEditorConfigurationChange())); diff --git a/src/vs/editor/contrib/peekView/browser/peekView.ts b/src/vs/editor/contrib/peekView/browser/peekView.ts index fe9cffb401e..c578441baa9 100644 --- a/src/vs/editor/contrib/peekView/browser/peekView.ts +++ b/src/vs/editor/contrib/peekView/browser/peekView.ts @@ -128,6 +128,7 @@ export abstract class PeekViewWidget extends ZoneWidget { this.disposed = true; // prevent consumers who dispose on onDidClose from looping super.dispose(); this._onDidClose.fire(this); + this._onDidClose.dispose(); const e = observableCodeEditor(this.editor); e.openedPeekWidgets.set(e.openedPeekWidgets.get() - 1, undefined); diff --git a/src/vs/editor/contrib/rename/browser/renameWidget.ts b/src/vs/editor/contrib/rename/browser/renameWidget.ts index 5ec01001456..b7e32811605 100644 --- a/src/vs/editor/contrib/rename/browser/renameWidget.ts +++ b/src/vs/editor/contrib/rename/browser/renameWidget.ts @@ -905,11 +905,11 @@ class InputWithButton implements IDisposable { private _sparkleIcon: HTMLElement | undefined; private _stopIcon: HTMLElement | undefined; - private readonly _onDidInputChange = new Emitter(); - public readonly onDidInputChange = this._onDidInputChange.event; - private readonly _disposables = new DisposableStore(); + private readonly _onDidInputChange = this._disposables.add(new Emitter()); + public readonly onDidInputChange = this._onDidInputChange.event; + get domNode() { if (!this._domNode) { diff --git a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts index 8e94fe1ef61..af10b515098 100644 --- a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts @@ -319,6 +319,11 @@ export class SuggestWidget implements IDisposable { this._showTimeout.dispose(); this._contentWidget.dispose(); this.element.dispose(); + this._onDidSelect.dispose(); + this._onDidFocus.dispose(); + this._onDidHide.dispose(); + this._onDidShow.dispose(); + this._onDetailsKeydown.dispose(); } private _onEditorMouseDown(mouseEvent: IEditorMouseEvent): void { diff --git a/src/vs/editor/contrib/suggest/browser/suggestWidgetDetails.ts b/src/vs/editor/contrib/suggest/browser/suggestWidgetDetails.ts index c13978ec43f..9d42306730d 100644 --- a/src/vs/editor/contrib/suggest/browser/suggestWidgetDetails.ts +++ b/src/vs/editor/contrib/suggest/browser/suggestWidgetDetails.ts @@ -82,6 +82,8 @@ export class SuggestDetailsWidget { dispose(): void { this._disposables.dispose(); this._renderDisposeable.dispose(); + this._onDidClose.dispose(); + this._onDidChangeContents.dispose(); } private _configureFont(): void { diff --git a/src/vs/platform/accessibility/browser/accessibilityService.ts b/src/vs/platform/accessibility/browser/accessibilityService.ts index d61976dcefc..d6db2a65b33 100644 --- a/src/vs/platform/accessibility/browser/accessibilityService.ts +++ b/src/vs/platform/accessibility/browser/accessibilityService.ts @@ -18,14 +18,14 @@ export class AccessibilityService extends Disposable implements IAccessibilitySe private _accessibilityModeEnabledContext: IContextKey; protected _accessibilitySupport = AccessibilitySupport.Unknown; - protected readonly _onDidChangeScreenReaderOptimized = new Emitter(); + protected readonly _onDidChangeScreenReaderOptimized = this._register(new Emitter()); protected _configMotionReduced: 'auto' | 'on' | 'off'; protected _systemMotionReduced: boolean; - protected readonly _onDidChangeReducedMotion = new Emitter(); + protected readonly _onDidChangeReducedMotion = this._register(new Emitter()); private _linkUnderlinesEnabled: boolean; - protected readonly _onDidChangeLinkUnderline = new Emitter(); + protected readonly _onDidChangeLinkUnderline = this._register(new Emitter()); constructor( @IContextKeyService private readonly _contextKeyService: IContextKeyService, diff --git a/src/vs/platform/extensionManagement/common/extensionEnablementService.ts b/src/vs/platform/extensionManagement/common/extensionEnablementService.ts index 85498cbfa74..a39576f9cff 100644 --- a/src/vs/platform/extensionManagement/common/extensionEnablementService.ts +++ b/src/vs/platform/extensionManagement/common/extensionEnablementService.ts @@ -14,7 +14,7 @@ export class GlobalExtensionEnablementService extends Disposable implements IGlo declare readonly _serviceBrand: undefined; - private _onDidChangeEnablement = new Emitter<{ readonly extensions: IExtensionIdentifier[]; readonly source?: string }>(); + private _onDidChangeEnablement = this._register(new Emitter<{ readonly extensions: IExtensionIdentifier[]; readonly source?: string }>()); readonly onDidChangeEnablement: Event<{ readonly extensions: IExtensionIdentifier[]; readonly source?: string }> = this._onDidChangeEnablement.event; private readonly storageManager: StorageManager; diff --git a/src/vs/platform/menubar/electron-main/menubar.ts b/src/vs/platform/menubar/electron-main/menubar.ts index d8f65c50b4d..0594c7e23ef 100644 --- a/src/vs/platform/menubar/electron-main/menubar.ts +++ b/src/vs/platform/menubar/electron-main/menubar.ts @@ -82,9 +82,9 @@ export class Menubar extends Disposable { ) { super(); - this.menuUpdater = new RunOnceScheduler(() => this.doUpdateMenu(), 0); + this.menuUpdater = this._register(new RunOnceScheduler(() => this.doUpdateMenu(), 0)); - this.menuGC = new RunOnceScheduler(() => { this.oldMenus = []; }, 10000); + this.menuGC = this._register(new RunOnceScheduler(() => { this.oldMenus = []; }, 10000)); this.menubarMenus = Object.create(null); this.keybindings = Object.create(null); diff --git a/src/vs/platform/policy/node/nativePolicyService.ts b/src/vs/platform/policy/node/nativePolicyService.ts index 5b08cd99480..feb4ba1f2fb 100644 --- a/src/vs/platform/policy/node/nativePolicyService.ts +++ b/src/vs/platform/policy/node/nativePolicyService.ts @@ -12,7 +12,7 @@ import { ILogService } from '../../log/common/log.js'; export class NativePolicyService extends AbstractPolicyService implements IPolicyService { - private throttler = new Throttler(); + private throttler = this._register(new Throttler()); private readonly watcher = this._register(new MutableDisposable()); constructor( diff --git a/src/vs/platform/quickinput/browser/quickInputList.ts b/src/vs/platform/quickinput/browser/quickInputList.ts index 21dfbc49628..8580b264014 100644 --- a/src/vs/platform/quickinput/browser/quickInputList.ts +++ b/src/vs/platform/quickinput/browser/quickInputList.ts @@ -686,13 +686,13 @@ export class QuickInputList extends Disposable { //#region QuickInputList Events - private readonly _onKeyDown = new Emitter(); + private readonly _onKeyDown = this._register(new Emitter()); /** * Event that is fired when the tree receives a keydown. */ readonly onKeyDown: Event = this._onKeyDown.event; - private readonly _onLeave = new Emitter(); + private readonly _onLeave = this._register(new Emitter()); /** * Event that is fired when the tree would no longer have focus. */ @@ -710,13 +710,13 @@ export class QuickInputList extends Disposable { private readonly _checkedElementsObservable = observableValueOpts({ equalsFn: equals }, new Array()); readonly onChangedCheckedElements: Event = Event.fromObservable(this._checkedElementsObservable, this._store); - private readonly _onButtonTriggered = new Emitter>(); + private readonly _onButtonTriggered = this._register(new Emitter>()); onButtonTriggered = this._onButtonTriggered.event; - private readonly _onSeparatorButtonTriggered = new Emitter(); + private readonly _onSeparatorButtonTriggered = this._register(new Emitter()); onSeparatorButtonTriggered = this._onSeparatorButtonTriggered.event; - private readonly _elementChecked = new Emitter<{ element: IQuickPickElement; checked: boolean }>(); + private readonly _elementChecked = this._register(new Emitter<{ element: IQuickPickElement; checked: boolean }>()); private readonly _elementCheckedEventBufferer = new EventBufferer(); //#endregion diff --git a/src/vs/platform/quickinput/browser/tree/quickInputTreeController.ts b/src/vs/platform/quickinput/browser/tree/quickInputTreeController.ts index 24d2cfc380f..896564c768a 100644 --- a/src/vs/platform/quickinput/browser/tree/quickInputTreeController.ts +++ b/src/vs/platform/quickinput/browser/tree/quickInputTreeController.ts @@ -62,7 +62,7 @@ export class QuickInputTreeController extends Disposable { private readonly _onDidCheckedLeafItemsChange = this._register(new Emitter>()); readonly onDidChangeCheckedLeafItems = this._onDidCheckedLeafItemsChange.event; - private readonly _onLeave = new Emitter(); + private readonly _onLeave = this._register(new Emitter()); /** * Event that is fired when the tree would no longer have focus. */ diff --git a/src/vs/platform/remote/browser/browserSocketFactory.ts b/src/vs/platform/remote/browser/browserSocketFactory.ts index cad70612060..eafeef861a1 100644 --- a/src/vs/platform/remote/browser/browserSocketFactory.ts +++ b/src/vs/platform/remote/browser/browserSocketFactory.ts @@ -49,7 +49,7 @@ export interface IWebSocket { class BrowserWebSocket extends Disposable implements IWebSocket { - private readonly _onData = new Emitter(); + private readonly _onData = this._register(new Emitter()); public readonly onData = this._onData.event; private readonly _onOpen = this._register(new Emitter()); diff --git a/src/vs/platform/remoteTunnel/node/remoteTunnelService.ts b/src/vs/platform/remoteTunnel/node/remoteTunnelService.ts index e5bf1f53c1c..bae34610f67 100644 --- a/src/vs/platform/remoteTunnel/node/remoteTunnelService.ts +++ b/src/vs/platform/remoteTunnel/node/remoteTunnelService.ts @@ -95,7 +95,7 @@ export class RemoteTunnelService extends Disposable implements IRemoteTunnelServ ) { super(); this._logger = this._register(loggerService.createLogger(joinPath(environmentService.logsHome, `${LOG_ID}.log`), { id: LOG_ID, name: LOGGER_NAME })); - this._startTunnelProcessDelayer = new Delayer(100); + this._startTunnelProcessDelayer = this._register(new Delayer(100)); this._register(this._logger.onDidChangeLogLevel(l => this._logger.info('Log level changed to ' + LogLevelToString(l)))); diff --git a/src/vs/platform/terminal/node/ptyService.ts b/src/vs/platform/terminal/node/ptyService.ts index 0cde9e762e1..a600f7b27d1 100644 --- a/src/vs/platform/terminal/node/ptyService.ts +++ b/src/vs/platform/terminal/node/ptyService.ts @@ -151,7 +151,7 @@ export class PtyService extends Disposable implements IPtyService { })); this._detachInstanceRequestStore = this._register(new RequestStore(undefined, this._logService)); - this._detachInstanceRequestStore.onCreateRequest(this._onDidRequestDetach.fire, this._onDidRequestDetach); + this._register(this._detachInstanceRequestStore.onCreateRequest(this._onDidRequestDetach.fire, this._onDidRequestDetach)); this._autoRepliesContribution = new AutoRepliesPtyServiceContribution(this._logService); diff --git a/src/vs/platform/terminal/node/windowsShellHelper.ts b/src/vs/platform/terminal/node/windowsShellHelper.ts index 1f32cebaa58..73254c4d241 100644 --- a/src/vs/platform/terminal/node/windowsShellHelper.ts +++ b/src/vs/platform/terminal/node/windowsShellHelper.ts @@ -49,9 +49,9 @@ export class WindowsShellHelper extends Disposable implements IWindowsShellHelpe get shellType(): TerminalShellType | undefined { return this._shellType; } private _shellTitle: string = ''; get shellTitle(): string { return this._shellTitle; } - private readonly _onShellNameChanged = new Emitter(); + private readonly _onShellNameChanged = this._register(new Emitter()); get onShellNameChanged(): Event { return this._onShellNameChanged.event; } - private readonly _onShellTypeChanged = new Emitter(); + private readonly _onShellTypeChanged = this._register(new Emitter()); get onShellTypeChanged(): Event { return this._onShellTypeChanged.event; } constructor( diff --git a/src/vs/platform/userDataSync/common/userDataSyncEnablementService.ts b/src/vs/platform/userDataSync/common/userDataSyncEnablementService.ts index fef99758ee1..a425fcc2437 100644 --- a/src/vs/platform/userDataSync/common/userDataSyncEnablementService.ts +++ b/src/vs/platform/userDataSync/common/userDataSyncEnablementService.ts @@ -16,10 +16,10 @@ export class UserDataSyncEnablementService extends Disposable implements IUserDa _serviceBrand: undefined; - private _onDidChangeEnablement = new Emitter(); + private _onDidChangeEnablement = this._register(new Emitter()); readonly onDidChangeEnablement: Event = this._onDidChangeEnablement.event; - private _onDidChangeResourceEnablement = new Emitter<[SyncResource, boolean]>(); + private _onDidChangeResourceEnablement = this._register(new Emitter<[SyncResource, boolean]>()); readonly onDidChangeResourceEnablement: Event<[SyncResource, boolean]> = this._onDidChangeResourceEnablement.event; constructor( diff --git a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts index 4bd53d45f69..18340a8ae9a 100644 --- a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts +++ b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts @@ -663,7 +663,7 @@ class StatusbarPart extends Part implements IStatusbarEntryContainer { const statusBarFocusColor = this.getColor(STATUS_BAR_FOCUS_BORDER); if (!this.styleElement) { - this.styleElement = createStyleSheet(container); + this.styleElement = createStyleSheet(container, undefined, this._store); } this.styleElement.textContent = ` diff --git a/src/vs/workbench/browser/parts/titlebar/windowTitle.ts b/src/vs/workbench/browser/parts/titlebar/windowTitle.ts index a182e124a2a..d2a6791f83a 100644 --- a/src/vs/workbench/browser/parts/titlebar/windowTitle.ts +++ b/src/vs/workbench/browser/parts/titlebar/windowTitle.ts @@ -64,7 +64,7 @@ export class WindowTitle extends Disposable { private readonly activeEditorListeners = this._register(new DisposableStore()); private readonly titleUpdater = this._register(new RunOnceScheduler(() => this.doUpdateTitle(), 0)); - private readonly onDidChangeEmitter = new Emitter(); + private readonly onDidChangeEmitter = this._register(new Emitter()); readonly onDidChange = this.onDidChangeEmitter.event; get value() { return this.title ?? ''; } diff --git a/src/vs/workbench/browser/parts/views/treeView.ts b/src/vs/workbench/browser/parts/views/treeView.ts index c971d405e21..1c9305bd780 100644 --- a/src/vs/workbench/browser/parts/views/treeView.ts +++ b/src/vs/workbench/browser/parts/views/treeView.ts @@ -1823,6 +1823,7 @@ class TreeMenus implements IDisposable { dispose() { this.contextKeyService = undefined; + this._onDidChange.dispose(); } } diff --git a/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane.ts b/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane.ts index 267b9be32f5..4d5d76768f0 100644 --- a/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane.ts +++ b/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane.ts @@ -104,6 +104,7 @@ export class BulkEditPane extends ViewPane { override dispose(): void { this._tree.dispose(); this._disposables.dispose(); + this._sessionDisposables.dispose(); super.dispose(); } diff --git a/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditTree.ts b/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditTree.ts index 6c78277c3d6..31556d785ce 100644 --- a/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditTree.ts +++ b/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditTree.ts @@ -668,7 +668,9 @@ export class TextEditElementRenderer implements ITreeRenderer { diff --git a/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.ts b/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.ts index 9cf80f365d8..ad2c82a5abd 100644 --- a/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.ts +++ b/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.ts @@ -29,7 +29,7 @@ import { Event } from '../../../../../base/common/event.js'; import { Dimension } from '../../../../../base/browser/dom.js'; import { registerColor } from '../../../../../platform/theme/common/colorRegistry.js'; import { PANEL_BORDER } from '../../../../common/theme.js'; -import { DisposableStore } from '../../../../../base/common/lifecycle.js'; +import { DisposableStore, MutableDisposable } from '../../../../../base/common/lifecycle.js'; import { IContextKey, IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js'; import { CONTEXT_MODELS_EDITOR } from '../../common/constants.js'; @@ -134,6 +134,7 @@ export class ChatManagementEditor extends EditorPane { private readonly commandService: ICommandService; private readonly chatEntitlementService: IChatEntitlementService; + private readonly actionButtonClickListener = this._register(new MutableDisposable()); constructor( group: IEditorGroup, @@ -390,7 +391,7 @@ export class ChatManagementEditor extends EditorPane { } this.actionButton.label = buttonLabel; - this.actionButton.onDidClick(() => { + this.actionButtonClickListener.value = this.actionButton.onDidClick(() => { this.commandService.executeCommand(commandId); }); } else { diff --git a/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.ts b/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.ts index 7033bf061e1..3281126a9a2 100644 --- a/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.ts @@ -891,7 +891,7 @@ export class ChatModelsWidget extends Disposable { super(); this.searchFocusContextKey = CONTEXT_MODELS_SEARCH_FOCUS.bindTo(contextKeyService); - this.delayedFiltering = new Delayer(200); + this.delayedFiltering = this._register(new Delayer(200)); this.viewModel = this._register(this.instantiationService.createInstance(ChatModelsViewModel)); this.element = DOM.$('.models-widget'); this.create(this.element); diff --git a/src/vs/workbench/contrib/chat/browser/chatManagement/chatUsageWidget.ts b/src/vs/workbench/contrib/chat/browser/chatManagement/chatUsageWidget.ts index b8ed68c27f1..d33b5a1524c 100644 --- a/src/vs/workbench/contrib/chat/browser/chatManagement/chatUsageWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/chatManagement/chatUsageWidget.ts @@ -16,7 +16,7 @@ const $ = DOM.$; export class ChatUsageWidget extends Disposable { - private readonly _onDidChangeContentHeight = new Emitter(); + private readonly _onDidChangeContentHeight = this._register(new Emitter()); readonly onDidChangeContentHeight = this._onDidChangeContentHeight.event; readonly element: HTMLElement; diff --git a/src/vs/workbench/contrib/chat/browser/languageModelsConfigurationService.ts b/src/vs/workbench/contrib/chat/browser/languageModelsConfigurationService.ts index efed13bcbb7..1c695e2ded0 100644 --- a/src/vs/workbench/contrib/chat/browser/languageModelsConfigurationService.ts +++ b/src/vs/workbench/contrib/chat/browser/languageModelsConfigurationService.ts @@ -37,7 +37,7 @@ export class LanguageModelsConfigurationService extends Disposable implements IL private readonly modelsConfigurationFile: URI; get configurationFile(): URI { return this.modelsConfigurationFile; } - private readonly _onDidChangeLanguageModelGroups = new Emitter(); + private readonly _onDidChangeLanguageModelGroups = this._register(new Emitter()); readonly onDidChangeLanguageModelGroups: Event = this._onDidChangeLanguageModelGroups.event; private languageModelsProviderGroups: LanguageModelsProviderGroups = []; diff --git a/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.ts b/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.ts index ad8a275652b..95fa26ab65d 100644 --- a/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.ts +++ b/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.ts @@ -101,7 +101,7 @@ export class LanguageModelToolsService extends Disposable implements ILanguageMo readonly onDidInvokeTool = this._onDidInvokeTool.event; /** Throttle tools updates because it sends all tools and runs on context key updates */ - private readonly _onDidChangeToolsScheduler = new RunOnceScheduler(() => this._onDidChangeTools.fire(), 750); + private readonly _onDidChangeToolsScheduler = this._register(new RunOnceScheduler(() => this._onDidChangeTools.fire(), 750)); private readonly _tools = new Map(); private readonly _toolContextKeys = new Set(); private readonly _ctxToolsCount: IContextKey; diff --git a/src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts b/src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts index 8e4414f6a24..148f548ca4f 100644 --- a/src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts +++ b/src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts @@ -191,7 +191,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer()); readonly onDidClickFollowup: Event = this._onDidClickFollowup.event; - private readonly _onDidClickRerunWithAgentOrCommandDetection = new Emitter<{ readonly sessionResource: URI; readonly requestId: string }>(); + private readonly _onDidClickRerunWithAgentOrCommandDetection = this._register(new Emitter<{ readonly sessionResource: URI; readonly requestId: string }>()); readonly onDidClickRerunWithAgentOrCommandDetection = this._onDidClickRerunWithAgentOrCommandDetection.event; diff --git a/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts b/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts index 9f2b79de590..92b514dabd2 100644 --- a/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts @@ -196,13 +196,13 @@ export class ChatWidget extends Disposable implements IChatWidget { private _onDidChangeParsedInput = this._register(new Emitter()); readonly onDidChangeParsedInput = this._onDidChangeParsedInput.event; - private readonly _onWillMaybeChangeHeight = new Emitter(); + private readonly _onWillMaybeChangeHeight = this._register(new Emitter()); readonly onWillMaybeChangeHeight: Event = this._onWillMaybeChangeHeight.event; private _onDidChangeHeight = this._register(new Emitter()); readonly onDidChangeHeight = this._onDidChangeHeight.event; - private readonly _onDidChangeContentHeight = new Emitter(); + private readonly _onDidChangeContentHeight = this._register(new Emitter()); readonly onDidChangeContentHeight: Event = this._onDidChangeContentHeight.event; private _onDidChangeEmptyState = this._register(new Emitter()); diff --git a/src/vs/workbench/contrib/codeEditor/browser/outline/documentSymbolsOutline.ts b/src/vs/workbench/contrib/codeEditor/browser/outline/documentSymbolsOutline.ts index e83d4d5d4cc..dc45f781eb0 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/outline/documentSymbolsOutline.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/outline/documentSymbolsOutline.ts @@ -110,7 +110,7 @@ class DocumentSymbolBreadcrumbsSource implements IBreadcrumbsDataSource { private readonly _disposables = new DisposableStore(); - private readonly _onDidChange = new Emitter(); + private readonly _onDidChange = this._disposables.add(new Emitter()); readonly onDidChange: Event = this._onDidChange.event; diff --git a/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts b/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts index b55067b5ac4..1dce3a40681 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts @@ -259,7 +259,7 @@ class EditorWordWrapContextKeyTracker extends Disposable implements IWorkbenchCo this._canToggleWordWrap = CAN_TOGGLE_WORD_WRAP.bindTo(this._contextService); this._editorWordWrap = EDITOR_WORD_WRAP.bindTo(this._contextService); this._activeEditor = null; - this._activeEditorListener = new DisposableStore(); + this._activeEditorListener = this._register(new DisposableStore()); this._update(); } diff --git a/src/vs/workbench/contrib/comments/browser/commentNode.ts b/src/vs/workbench/contrib/comments/browser/commentNode.ts index b4ded353a75..ee1177e1eb3 100644 --- a/src/vs/workbench/contrib/comments/browser/commentNode.ts +++ b/src/vs/workbench/contrib/comments/browser/commentNode.ts @@ -91,7 +91,7 @@ export class CommentNode extends Disposable { private _commentFormActions: CommentFormActions | null = null; private _commentEditorActions: CommentFormActions | null = null; - private readonly _onDidClick = new Emitter>(); + private readonly _onDidClick = this._register(new Emitter>()); public get domNode(): HTMLElement { return this._domNode; diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadBody.ts b/src/vs/workbench/contrib/comments/browser/commentThreadBody.ts index 08b0f2bd745..7f3deff2eda 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadBody.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadBody.ts @@ -25,7 +25,7 @@ export class CommentThreadBody extends D private _commentElements: CommentNode[] = []; private _resizeObserver: MutationObserver | null = null; private _focusedComment: number | undefined = undefined; - private _onDidResize = new Emitter(); + private _onDidResize = this._register(new Emitter()); onDidResize = this._onDidResize.event; private _commentDisposable = new DisposableMap, DisposableStore>(); diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts index 7fb4e06542e..8e31f0b2116 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts @@ -45,7 +45,7 @@ export class CommentThreadWidget extends private _threadIsEmpty: IContextKey; private _commentThreadContextValue: IContextKey; private _focusedContextKey: IContextKey; - private _onDidResize = new Emitter(); + private _onDidResize = this._register(new Emitter()); onDidResize = this._onDidResize.event; private _commentThreadState: languages.CommentThreadState | undefined; diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts index 85e5fba39ef..3a54c6236d8 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts @@ -588,5 +588,8 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget this._globalToDispose.dispose(); this._commentThreadDisposables.forEach(global => global.dispose()); this._onDidClose.fire(undefined); + this._onDidClose.dispose(); + this._onDidCreateThread.dispose(); + this._onDidChangeExpandedState.dispose(); } } diff --git a/src/vs/workbench/contrib/comments/browser/commentsController.ts b/src/vs/workbench/contrib/comments/browser/commentsController.ts index da053b77af1..de5f8bea30f 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsController.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsController.ts @@ -506,7 +506,7 @@ export class CommentController extends Disposable implements IEditorContribution this.editor = editor; - this._commentingRangeDecorator = new CommentingRangeDecorator(); + this._commentingRangeDecorator = this._register(new CommentingRangeDecorator()); this._register(this._commentingRangeDecorator.onDidChangeDecorationsCount(count => { if (count === 0) { this.clearEditorListeners(); diff --git a/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts b/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts index d7c743c9188..bf2f59505c9 100644 --- a/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts +++ b/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts @@ -77,7 +77,7 @@ export class ConfigurationManager implements IConfigurationManager { @ILogService private readonly logService: ILogService, ) { this.configProviders = []; - this.toDispose = [this._onDidChangeConfigurationProviders]; + this.toDispose = [this._onDidChangeConfigurationProviders, this._onDidSelectConfigurationName]; this.initLaunches(); this.setCompoundSchemaValues(); this.registerListeners(); diff --git a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts index 008d4b876b4..48e3c89d7cf 100644 --- a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts +++ b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts @@ -959,12 +959,9 @@ export class DebugEditorContribution implements IDebugEditorContribution { } dispose(): void { - if (this.hoverWidget) { - this.hoverWidget.dispose(); - } - if (this.configurationWidget) { - this.configurationWidget.dispose(); - } + this.hoverWidget?.dispose(); + this.configurationWidget?.dispose(); + this.exceptionWidget?.dispose(); this.toDispose = dispose(this.toDispose); } } diff --git a/src/vs/workbench/contrib/debug/browser/debugHover.ts b/src/vs/workbench/contrib/debug/browser/debugHover.ts index 28f66c5d519..fe8ae2b6ab0 100644 --- a/src/vs/workbench/contrib/debug/browser/debugHover.ts +++ b/src/vs/workbench/contrib/debug/browser/debugHover.ts @@ -153,6 +153,7 @@ export class DebugHoverWidget implements IContentWidget { }); this.toDispose.push(VisualizedVariableRenderer.rendererOnVisualizationRange(this.debugService.getViewModel(), this.tree)); + this.toDispose.push(this.tree); this.valueContainer = $('.value'); this.valueContainer.tabIndex = 0; diff --git a/src/vs/workbench/contrib/debug/browser/debugService.ts b/src/vs/workbench/contrib/debug/browser/debugService.ts index d298a4e7dec..a5cc44f136c 100644 --- a/src/vs/workbench/contrib/debug/browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/browser/debugService.ts @@ -136,7 +136,7 @@ export class DebugService implements IDebugService { this.model = this.instantiationService.createInstance(DebugModel, this.debugStorage); this.telemetry = this.instantiationService.createInstance(DebugTelemetry, this.model); - this.viewModel = new ViewModel(contextKeyService); + this.viewModel = this.disposables.add(new ViewModel(contextKeyService)); this.taskRunner = this.instantiationService.createInstance(DebugTaskRunner); this.disposables.add(this.fileService.onDidFilesChange(e => this.onFileChanges(e))); diff --git a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts index 8971b30a2b0..0c0e9e53653 100644 --- a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts @@ -14,7 +14,7 @@ import { IDebugAdapter, IConfig, AdapterEndEvent, IDebugger } from '../common/de import { IExtensionHostDebugService, IOpenExtensionWindowResult } from '../../../../platform/debug/common/extensionHostDebug.js'; import { URI } from '../../../../base/common/uri.js'; import { IOpenerService } from '../../../../platform/opener/common/opener.js'; -import { IDisposable, dispose } from '../../../../base/common/lifecycle.js'; +import { DisposableStore, IDisposable } from '../../../../base/common/lifecycle.js'; import { CancellationToken } from '../../../../base/common/cancellation.js'; import { INotificationService, Severity } from '../../../../platform/notification/common/notification.js'; import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js'; @@ -55,31 +55,31 @@ export class RawDebugSession implements IDisposable { private startTime = 0; private didReceiveStoppedEvent = false; + private readonly toDispose = new DisposableStore(); + // DAP events - private readonly _onDidInitialize = new Emitter(); - private readonly _onDidStop = new Emitter(); - private readonly _onDidContinued = new Emitter(); - private readonly _onDidTerminateDebugee = new Emitter(); - private readonly _onDidExitDebugee = new Emitter(); - private readonly _onDidThread = new Emitter(); - private readonly _onDidOutput = new Emitter(); - private readonly _onDidBreakpoint = new Emitter(); - private readonly _onDidLoadedSource = new Emitter(); - private readonly _onDidProgressStart = new Emitter(); - private readonly _onDidProgressUpdate = new Emitter(); - private readonly _onDidProgressEnd = new Emitter(); - private readonly _onDidInvalidated = new Emitter(); - private readonly _onDidInvalidateMemory = new Emitter(); - private readonly _onDidCustomEvent = new Emitter(); - private readonly _onDidEvent = new Emitter(); + private readonly _onDidInitialize = this.toDispose.add(new Emitter()); + private readonly _onDidStop = this.toDispose.add(new Emitter()); + private readonly _onDidContinued = this.toDispose.add(new Emitter()); + private readonly _onDidTerminateDebugee = this.toDispose.add(new Emitter()); + private readonly _onDidExitDebugee = this.toDispose.add(new Emitter()); + private readonly _onDidThread = this.toDispose.add(new Emitter()); + private readonly _onDidOutput = this.toDispose.add(new Emitter()); + private readonly _onDidBreakpoint = this.toDispose.add(new Emitter()); + private readonly _onDidLoadedSource = this.toDispose.add(new Emitter()); + private readonly _onDidProgressStart = this.toDispose.add(new Emitter()); + private readonly _onDidProgressUpdate = this.toDispose.add(new Emitter()); + private readonly _onDidProgressEnd = this.toDispose.add(new Emitter()); + private readonly _onDidInvalidated = this.toDispose.add(new Emitter()); + private readonly _onDidInvalidateMemory = this.toDispose.add(new Emitter()); + private readonly _onDidCustomEvent = this.toDispose.add(new Emitter()); + private readonly _onDidEvent = this.toDispose.add(new Emitter()); // DA events - private readonly _onDidExitAdapter = new Emitter(); + private readonly _onDidExitAdapter = this.toDispose.add(new Emitter()); private debugAdapter: IDebugAdapter | null; private stoppedSinceLastStep = false; - private toDispose: IDisposable[] = []; - constructor( debugAdapter: IDebugAdapter, public readonly dbgr: IDebugger, @@ -93,11 +93,11 @@ export class RawDebugSession implements IDisposable { this.debugAdapter = debugAdapter; this._capabilities = Object.create(null); - this.toDispose.push(this.debugAdapter.onError(err => { + this.toDispose.add(this.debugAdapter.onError(err => { this.shutdown(err); })); - this.toDispose.push(this.debugAdapter.onExit(code => { + this.toDispose.add(this.debugAdapter.onExit(code => { if (code !== 0) { this.shutdown(new Error(`exit code: ${code}`)); } else { @@ -834,6 +834,6 @@ export class RawDebugSession implements IDisposable { } dispose(): void { - dispose(this.toDispose); + this.toDispose.dispose(); } } diff --git a/src/vs/workbench/contrib/debug/browser/repl.ts b/src/vs/workbench/contrib/debug/browser/repl.ts index e610aca89b3..7533ef033b6 100644 --- a/src/vs/workbench/contrib/debug/browser/repl.ts +++ b/src/vs/workbench/contrib/debug/browser/repl.ts @@ -717,7 +717,7 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget { })); // Make sure to select the session if debugging is already active this.selectSession(); - this.styleElement = domStylesheetsJs.createStyleSheet(this.container); + this.styleElement = domStylesheetsJs.createStyleSheet(this.container, undefined, this._store); this.onDidStyleChange(); } diff --git a/src/vs/workbench/contrib/debug/browser/variablesView.ts b/src/vs/workbench/contrib/debug/browser/variablesView.ts index 9a087c15dd0..f18d41bf23c 100644 --- a/src/vs/workbench/contrib/debug/browser/variablesView.ts +++ b/src/vs/workbench/contrib/debug/browser/variablesView.ts @@ -90,7 +90,7 @@ export class VariablesView extends ViewPane implements IDebugViewWithVariables { super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, hoverService); // Use scheduler to prevent unnecessary flashing - this.updateTreeScheduler = new RunOnceScheduler(async () => { + this.updateTreeScheduler = this._register(new RunOnceScheduler(async () => { const stackFrame = this.debugService.getViewModel().focusedStackFrame; this.needsRefresh = false; @@ -116,7 +116,7 @@ export class VariablesView extends ViewPane implements IDebugViewWithVariables { this.autoExpandedScopes.add(toExpand.getId()); await this.tree.expand(toExpand); } - }, 400); + }, 400)); } protected override renderBody(container: HTMLElement): void { diff --git a/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts b/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts index a2c421aaf1e..f290f709ae5 100644 --- a/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts +++ b/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts @@ -74,10 +74,10 @@ export class WatchExpressionsView extends ViewPane implements IDebugViewWithVari ) { super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, hoverService); - this.watchExpressionsUpdatedScheduler = new RunOnceScheduler(() => { + this.watchExpressionsUpdatedScheduler = this._register(new RunOnceScheduler(() => { this.needsRefresh = false; this.tree.updateChildren(); - }, 50); + }, 50)); this.watchExpressionsExist = CONTEXT_WATCH_EXPRESSIONS_EXIST.bindTo(contextKeyService); this.watchExpressionsExist.set(this.debugService.getModel().getWatchExpressions().length > 0); this.expressionRenderer = instantiationService.createInstance(DebugExpressionRenderer); diff --git a/src/vs/workbench/contrib/debug/common/debugViewModel.ts b/src/vs/workbench/contrib/debug/common/debugViewModel.ts index 20c2092da07..12825128fa7 100644 --- a/src/vs/workbench/contrib/debug/common/debugViewModel.ts +++ b/src/vs/workbench/contrib/debug/common/debugViewModel.ts @@ -4,11 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import { Emitter, Event } from '../../../../base/common/event.js'; +import { Disposable } from '../../../../base/common/lifecycle.js'; import { IContextKey, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js'; import { CONTEXT_DISASSEMBLE_REQUEST_SUPPORTED, CONTEXT_EXPRESSION_SELECTED, CONTEXT_FOCUSED_SESSION_IS_ATTACH, CONTEXT_FOCUSED_SESSION_IS_NO_DEBUG, CONTEXT_FOCUSED_STACK_FRAME_HAS_INSTRUCTION_POINTER_REFERENCE, CONTEXT_JUMP_TO_CURSOR_SUPPORTED, CONTEXT_LOADED_SCRIPTS_SUPPORTED, CONTEXT_MULTI_SESSION_DEBUG, CONTEXT_RESTART_FRAME_SUPPORTED, CONTEXT_SET_DATA_BREAKPOINT_BYTES_SUPPORTED, CONTEXT_SET_EXPRESSION_SUPPORTED, CONTEXT_SET_VARIABLE_SUPPORTED, CONTEXT_STEP_BACK_SUPPORTED, CONTEXT_STEP_INTO_TARGETS_SUPPORTED, CONTEXT_SUSPEND_DEBUGGEE_SUPPORTED, CONTEXT_TERMINATE_DEBUGGEE_SUPPORTED, CONTEXT_TERMINATE_THREADS_SUPPORTED, IDebugSession, IExpression, IExpressionContainer, IStackFrame, IThread, IViewModel } from './debug.js'; import { isSessionAttach } from './debugUtils.js'; -export class ViewModel implements IViewModel { +export class ViewModel extends Disposable implements IViewModel { firstSessionStart = true; @@ -16,13 +17,13 @@ export class ViewModel implements IViewModel { private _focusedSession: IDebugSession | undefined; private _focusedThread: IThread | undefined; private selectedExpression: { expression: IExpression; settingWatch: boolean } | undefined; - private readonly _onDidFocusSession = new Emitter(); - private readonly _onDidFocusThread = new Emitter<{ thread: IThread | undefined; explicit: boolean; session: IDebugSession | undefined }>(); - private readonly _onDidFocusStackFrame = new Emitter<{ stackFrame: IStackFrame | undefined; explicit: boolean; session: IDebugSession | undefined }>(); - private readonly _onDidSelectExpression = new Emitter<{ expression: IExpression; settingWatch: boolean } | undefined>(); - private readonly _onDidEvaluateLazyExpression = new Emitter(); - private readonly _onWillUpdateViews = new Emitter(); - private readonly _onDidChangeVisualization = new Emitter<{ original: IExpression; replacement: IExpression }>(); + private readonly _onDidFocusSession = this._register(new Emitter()); + private readonly _onDidFocusThread = this._register(new Emitter<{ thread: IThread | undefined; explicit: boolean; session: IDebugSession | undefined }>()); + private readonly _onDidFocusStackFrame = this._register(new Emitter<{ stackFrame: IStackFrame | undefined; explicit: boolean; session: IDebugSession | undefined }>()); + private readonly _onDidSelectExpression = this._register(new Emitter<{ expression: IExpression; settingWatch: boolean } | undefined>()); + private readonly _onDidEvaluateLazyExpression = this._register(new Emitter()); + private readonly _onWillUpdateViews = this._register(new Emitter()); + private readonly _onDidChangeVisualization = this._register(new Emitter<{ original: IExpression; replacement: IExpression }>()); private readonly visualized = new WeakMap(); private readonly preferredVisualizers = new Map(); private expressionSelectedContextKey!: IContextKey; @@ -44,6 +45,7 @@ export class ViewModel implements IViewModel { private focusedStackFrameHasInstructionPointerReference!: IContextKey; constructor(private contextKeyService: IContextKeyService) { + super(); contextKeyService.bufferChangeEvents(() => { this.expressionSelectedContextKey = CONTEXT_EXPRESSION_SELECTED.bindTo(contextKeyService); this.loadedScriptsSupportedContextKey = CONTEXT_LOADED_SCRIPTS_SUPPORTED.bindTo(contextKeyService); diff --git a/src/vs/workbench/contrib/debug/test/browser/debugViewModel.test.ts b/src/vs/workbench/contrib/debug/test/browser/debugViewModel.test.ts index f6d12fd9dcc..a179d8fcd74 100644 --- a/src/vs/workbench/contrib/debug/test/browser/debugViewModel.test.ts +++ b/src/vs/workbench/contrib/debug/test/browser/debugViewModel.test.ts @@ -20,6 +20,10 @@ suite('Debug - View Model', () => { model = new ViewModel(new MockContextKeyService()); }); + teardown(() => { + model.dispose(); + }); + ensureNoDisposablesAreLeakedInTestSuite(); test('focused stack frame', () => { diff --git a/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts b/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts index 7be90be5078..710e9607ae2 100644 --- a/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts +++ b/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts @@ -180,11 +180,11 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo this.registerContributedEditSessionOptions(); this._register(this.fileService.registerProvider(EditSessionsFileSystemProvider.SCHEMA, new EditSessionsFileSystemProvider(this.editSessionsStorageService))); - this.lifecycleService.onWillShutdown((e) => { + this._register(this.lifecycleService.onWillShutdown((e) => { if (e.reason !== ShutdownReason.RELOAD && this.editSessionsStorageService.isSignedIn && this.configurationService.getValue('workbench.experimental.cloudChanges.autoStore') === 'onShutdown' && !isWeb) { e.join(this.autoStoreEditSession(), { id: 'autoStoreWorkingChanges', label: localize('autoStoreWorkingChanges', 'Storing current working changes...') }); } - }); + })); this._register(this.editSessionsStorageService.onDidSignIn(() => this.updateAccountsMenuBadge())); this._register(this.editSessionsStorageService.onDidSignOut(() => this.updateAccountsMenuBadge())); } diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts index c897cfe7401..d1dacd0dc61 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts @@ -435,7 +435,7 @@ export class InstallAction extends ExtensionAction { this.updateLabel(); } - private readonly updateThrottler = new Throttler(); + private readonly updateThrottler = this._register(new Throttler()); public readonly options: InstallOptions; constructor( @@ -954,7 +954,7 @@ export class UpdateAction extends ExtensionAction { private static readonly EnabledClass = `${this.LABEL_ACTION_CLASS} update`; private static readonly DisabledClass = `${this.EnabledClass} disabled`; - private readonly updateThrottler = new Throttler(); + private readonly updateThrottler = this._register(new Throttler()); constructor( private readonly verbose: boolean, @@ -2542,7 +2542,7 @@ export class ExtensionStatusAction extends ExtensionAction { private readonly _onDidChangeStatus = this._register(new Emitter()); readonly onDidChangeStatus = this._onDidChangeStatus.event; - private readonly updateThrottler = new Throttler(); + private readonly updateThrottler = this._register(new Throttler()); constructor( @IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService, diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts b/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts index 942a2f4b91b..ae4fdd99cc5 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts @@ -567,7 +567,7 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer { return this._onChange.event; } private extensionsNotification: IExtensionsNotification & { readonly key: string } | undefined; - private readonly _onDidChangeExtensionsNotification = new Emitter(); + private readonly _onDidChangeExtensionsNotification = this._register(new Emitter()); readonly onDidChangeExtensionsNotification = this._onDidChangeExtensionsNotification.event; - private readonly _onReset = new Emitter(); + private readonly _onReset = this._register(new Emitter()); get onReset() { return this._onReset.event; } private installing: IExtension[] = []; diff --git a/src/vs/workbench/contrib/files/browser/explorerService.ts b/src/vs/workbench/contrib/files/browser/explorerService.ts index d99b810753c..2a770d78ff2 100644 --- a/src/vs/workbench/contrib/files/browser/explorerService.ts +++ b/src/vs/workbench/contrib/files/browser/explorerService.ts @@ -62,7 +62,7 @@ export class ExplorerService implements IExplorerService { this.disposables.add(this.model); this.disposables.add(this.fileService.onDidRunOperation(e => this.onDidRunOperation(e))); - this.onFileChangesScheduler = new RunOnceScheduler(async () => { + this.onFileChangesScheduler = this.disposables.add(new RunOnceScheduler(async () => { const events = this.fileChangeEvents; this.fileChangeEvents = []; @@ -98,7 +98,7 @@ export class ExplorerService implements IExplorerService { await this.refresh(false); } - }, ExplorerService.EXPLORER_FILE_CHANGES_REACT_DELAY); + }, ExplorerService.EXPLORER_FILE_CHANGES_REACT_DELAY)); this.disposables.add(this.fileService.onDidFilesChange(e => { this.fileChangeEvents.push(e); diff --git a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts index a4a00dfa7ea..ed7dbe07826 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts @@ -1245,6 +1245,7 @@ export class FilesFilter implements ITreeFilter { @IUriIdentityService private readonly uriIdentityService: IUriIdentityService, @IFileService private readonly fileService: IFileService ) { + this.toDispose.push(this._onDidChange); this.toDispose.push(this.contextService.onDidChangeWorkspaceFolders(() => this.updateConfiguration())); this.toDispose.push(this.configurationService.onDidChangeConfiguration((e) => { if (e.affectsConfiguration('files.exclude') || e.affectsConfiguration('explorer.excludeGitIgnore')) { diff --git a/src/vs/workbench/contrib/files/common/explorerModel.ts b/src/vs/workbench/contrib/files/common/explorerModel.ts index 468d501385d..ddba6b33bec 100644 --- a/src/vs/workbench/contrib/files/common/explorerModel.ts +++ b/src/vs/workbench/contrib/files/common/explorerModel.ts @@ -81,6 +81,7 @@ export class ExplorerModel implements IDisposable { } dispose(): void { + this._onDidChangeRoots.dispose(); dispose(this._listener); } } diff --git a/src/vs/workbench/contrib/markers/browser/markersTable.ts b/src/vs/workbench/contrib/markers/browser/markersTable.ts index 2065d259604..ca4d993ef62 100644 --- a/src/vs/workbench/contrib/markers/browser/markersTable.ts +++ b/src/vs/workbench/contrib/markers/browser/markersTable.ts @@ -37,6 +37,7 @@ const $ = DOM.$; interface IMarkerIconColumnTemplateData { readonly icon: HTMLElement; readonly actionBar: ActionBar; + readonly elementDisposables: DisposableStore; } interface IMarkerCodeColumnTemplateData { @@ -79,10 +80,12 @@ class MarkerSeverityColumnRenderer implements ITableRenderer action.id === QuickFixAction.ID ? this.instantiationService.createInstance(QuickFixActionViewItem, action, options) : undefined }); - return { actionBar, icon }; + return { actionBar, icon, elementDisposables: new DisposableStore() }; } renderElement(element: MarkerTableItem, index: number, templateData: IMarkerIconColumnTemplateData): void { + templateData.elementDisposables.clear(); + const toggleQuickFix = (enabled?: boolean) => { if (!isUndefinedOrNull(enabled)) { const container = DOM.findParentWithClass(templateData.icon, 'monaco-table-td')!; @@ -100,17 +103,20 @@ class MarkerSeverityColumnRenderer implements ITableRenderer toggleQuickFix(enabled)); - quickFixAction.onShowQuickFixes(() => { + templateData.elementDisposables.add(quickFixAction.onDidChange(({ enabled }) => toggleQuickFix(enabled))); + templateData.elementDisposables.add(quickFixAction.onShowQuickFixes(() => { const quickFixActionViewItem = templateData.actionBar.viewItems[0]; if (quickFixActionViewItem) { quickFixActionViewItem.showQuickFixes(); } - }); + })); } } - disposeTemplate(templateData: IMarkerIconColumnTemplateData): void { } + disposeTemplate(templateData: IMarkerIconColumnTemplateData): void { + templateData.elementDisposables.dispose(); + templateData.actionBar.dispose(); + } } class MarkerCodeColumnRenderer implements ITableRenderer { diff --git a/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts b/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts index 081478c7596..0176fb67045 100644 --- a/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts +++ b/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts @@ -711,7 +711,7 @@ export class MarkersViewModel extends Disposable { private bulkUpdate: boolean = false; private hoveredMarker: Marker | null = null; - private hoverDelayer: Delayer = new Delayer(300); + private hoverDelayer: Delayer = this._register(new Delayer(300)); private viewModeContextKey: IContextKey; constructor( diff --git a/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.ts b/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.ts index f915f609d19..1efef9d6396 100644 --- a/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.ts +++ b/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.ts @@ -19,7 +19,7 @@ export const conflictMarkers = { export class MergeMarkersController extends Disposable { private readonly viewZoneIds: string[] = []; - private readonly disposableStore = new DisposableStore(); + private readonly disposableStore = this._register(new DisposableStore()); public constructor( public readonly editor: ICodeEditor, diff --git a/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.ts b/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.ts index 5a2d17c919f..eb4a795bcd3 100644 --- a/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.ts +++ b/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.ts @@ -70,7 +70,7 @@ export abstract class CodeEditorView extends Disposable { h('div@editor'), ]), ]); - this._onDidViewChange = new Emitter(); + this._onDidViewChange = this._register(new Emitter()); this.view = { element: this.htmlElements.root, minimumWidth: DEFAULT_EDITOR_MIN_DIMENSIONS.width, diff --git a/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.ts b/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.ts index ba97c865ba2..17c9d460592 100644 --- a/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.ts +++ b/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.ts @@ -130,7 +130,7 @@ export class MergeEditor extends AbstractTextEditor { this.inputResultView.editor, ); this.scrollSynchronizer = this._register(new ScrollSynchronizer(this._viewModel, this.input1View, this.input2View, this.baseView, this.inputResultView, this._layoutModeObs)); - this._onDidChangeSizeConstraints = new Emitter(); + this._onDidChangeSizeConstraints = this._register(new Emitter()); this.onDidChangeSizeConstraints = this._onDidChangeSizeConstraints.event; this.baseViewDisposables = this._register(new DisposableStore()); this.showNonConflictingChangesStore = this.instantiationService.createInstance(PersistentStore, 'mergeEditor/showNonConflictingChanges'); diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts index ae53643d6d7..25020d79764 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts @@ -82,7 +82,7 @@ export class FindModel extends Disposable { ) { super(); - this._throttledDelayer = new Delayer(20); + this._throttledDelayer = this._register(new Delayer(20)); this._computePromise = null; this._register(_state.onFindReplaceStateChange(e => { diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.ts b/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.ts index 4a836cc19b0..7c3772033d8 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.ts @@ -74,7 +74,7 @@ export class NotebookVariablesView extends ViewPane { this.handleActiveEditorChange(false); this.dataSource = new NotebookVariableDataSource(this.notebookKernelService); - this.updateScheduler = new RunOnceScheduler(() => this.tree?.updateChildren(), 100); + this.updateScheduler = this._register(new RunOnceScheduler(() => this.tree?.updateChildren(), 100)); } protected override renderBody(container: HTMLElement): void { diff --git a/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.ts b/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.ts index 5f3ae5f09cd..ca43d2dcb48 100644 --- a/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.ts +++ b/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.ts @@ -26,7 +26,7 @@ import { InlineDecoration, InlineDecorationType } from '../../../../../../editor //TODO: allow client to set read-only - chateditsession should set read-only while making changes export class NotebookCellDiffDecorator extends DisposableStore { private _viewZones: string[] = []; - private readonly throttledDecorator = new ThrottledDelayer(50); + private readonly throttledDecorator = this.add(new ThrottledDelayer(50)); private diffForPreviouslyAppliedDecorators?: IDocumentDiff; private readonly perEditorDisposables = this.add(new DisposableStore()); diff --git a/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityProvider.ts b/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityProvider.ts index e035bb1179c..4c8c264e829 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityProvider.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityProvider.ts @@ -22,7 +22,7 @@ import { alert } from '../../../../base/browser/ui/aria/aria.js'; type executionUpdate = { cellHandle: number; state: NotebookCellExecutionState | undefined }; export class NotebookAccessibilityProvider extends Disposable implements IListAccessibilityProvider { - private readonly _onDidAriaLabelChange = new Emitter(); + private readonly _onDidAriaLabelChange = this._register(new Emitter()); private readonly onDidAriaLabelChange = this._onDidAriaLabelChange.event; constructor( diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineDataSource.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineDataSource.ts index cc0d3987e61..6e172f4a6ce 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineDataSource.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineDataSource.ts @@ -218,5 +218,6 @@ export class NotebookCellOutlineDataSource implements INotebookCellOutlineDataSo this._entries.length = 0; this._activeEntry = undefined; this._disposables.dispose(); + this._onDidChange.dispose(); } } diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts index 25755ec15f7..1bf893c2b75 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts @@ -177,7 +177,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD private readonly _instanceId: string; public readonly id: string; private _foldingRanges: FoldingRegions | null = null; - private _onDidFoldingStateChanged = new Emitter(); + private _onDidFoldingStateChanged = this._register(new Emitter()); readonly onDidFoldingStateChanged: Event = this._onDidFoldingStateChanged.event; private _hiddenRanges: ICellRange[] = []; private _focused: boolean = true; diff --git a/src/vs/workbench/contrib/output/browser/outputLinkProvider.ts b/src/vs/workbench/contrib/output/browser/outputLinkProvider.ts index 89591f8ed93..824155d84c2 100644 --- a/src/vs/workbench/contrib/output/browser/outputLinkProvider.ts +++ b/src/vs/workbench/contrib/output/browser/outputLinkProvider.ts @@ -34,7 +34,7 @@ export class OutputLinkProvider extends Disposable { ) { super(); - this.disposeWorkerScheduler = new RunOnceScheduler(() => this.disposeWorker(), OutputLinkProvider.DISPOSE_WORKER_TIME); + this.disposeWorkerScheduler = this._register(new RunOnceScheduler(() => this.disposeWorker(), OutputLinkProvider.DISPOSE_WORKER_TIME)); this.registerListeners(); this.updateLinkProviderWorker(); diff --git a/src/vs/workbench/contrib/output/common/outputChannelModel.ts b/src/vs/workbench/contrib/output/common/outputChannelModel.ts index 34940ddcb5a..1e768b2bda8 100644 --- a/src/vs/workbench/contrib/output/common/outputChannelModel.ts +++ b/src/vs/workbench/contrib/output/common/outputChannelModel.ts @@ -115,10 +115,10 @@ interface IContentProvider { class FileContentProvider extends Disposable implements IContentProvider { - private readonly _onDidAppend = new Emitter(); + private readonly _onDidAppend = this._register(new Emitter()); get onDidAppend() { return this._onDidAppend.event; } - private readonly _onDidReset = new Emitter(); + private readonly _onDidReset = this._register(new Emitter()); get onDidReset() { return this._onDidReset.event; } private watching: boolean = false; diff --git a/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts b/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts index 759f22b3926..6fce0410f84 100644 --- a/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts +++ b/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts @@ -133,14 +133,14 @@ export class KeybindingsEditor extends EditorPane imp @IAccessibilityService private readonly accessibilityService: IAccessibilityService ) { super(KeybindingsEditor.ID, group, telemetryService, themeService, storageService); - this.delayedFiltering = new Delayer(300); + this.delayedFiltering = this._register(new Delayer(300)); this._register(keybindingsService.onDidUpdateKeybindings(() => this.render(!!this.keybindingFocusContextKey.get()))); this.keybindingsEditorContextKey = CONTEXT_KEYBINDINGS_EDITOR.bindTo(this.contextKeyService); this.searchFocusContextKey = CONTEXT_KEYBINDINGS_SEARCH_FOCUS.bindTo(this.contextKeyService); this.keybindingFocusContextKey = CONTEXT_KEYBINDING_FOCUS.bindTo(this.contextKeyService); this.searchHasValueContextKey = CONTEXT_KEYBINDINGS_SEARCH_HAS_VALUE.bindTo(this.contextKeyService); - this.searchHistoryDelayer = new Delayer(500); + this.searchHistoryDelayer = this._register(new Delayer(500)); this.recordKeysAction = this._register(new Action(KEYBINDINGS_EDITOR_COMMAND_RECORD_SEARCH_KEYS, localize('recordKeysLabel', "Record Keys"), ThemeIcon.asClassName(keybindingsRecordKeysIcon))); this.recordKeysAction.checked = false; diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts b/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts index 7fa5fd339a9..5d78d73a69f 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts @@ -61,7 +61,7 @@ export class UserSettingsRenderer extends Disposable implements IPreferencesRend private settingHighlighter: SettingHighlighter; private editSettingActionRenderer: EditSettingRenderer; - private modelChangeDelayer: Delayer = new Delayer(200); + private modelChangeDelayer = this._register(new Delayer(200)); private associatedPreferencesModel!: IPreferencesEditorModel; private unsupportedSettingsRenderer: UnsupportedSettingsRenderer; @@ -194,7 +194,7 @@ class EditSettingRenderer extends Disposable { this.editPreferenceWidgetForCursorPosition = this._register(this.instantiationService.createInstance(EditPreferenceWidget, editor)); this.editPreferenceWidgetForMouseMove = this._register(this.instantiationService.createInstance(EditPreferenceWidget, editor)); - this.toggleEditPreferencesForMouseMoveDelayer = new Delayer(75); + this.toggleEditPreferencesForMouseMoveDelayer = this._register(new Delayer(75)); this._register(this.editPreferenceWidgetForCursorPosition.onClick(e => this.onEditSettingClicked(this.editPreferenceWidgetForCursorPosition, e))); this._register(this.editPreferenceWidgetForMouseMove.onClick(e => this.onEditSettingClicked(this.editPreferenceWidgetForMouseMove, e))); @@ -486,7 +486,7 @@ class SettingHighlighter extends Disposable { class UnsupportedSettingsRenderer extends Disposable implements languages.CodeActionProvider { - private renderingDelayer: Delayer = new Delayer(200); + private renderingDelayer = this._register(new Delayer(200)); private readonly codeActions = new ResourceMap<[Range, languages.CodeAction[]][]>(uri => this.uriIdentityService.extUri.getComparisonKey(uri)); @@ -791,7 +791,7 @@ class UnsupportedSettingsRenderer extends Disposable implements languages.CodeAc class McpSettingsRenderer extends Disposable implements languages.CodeActionProvider { - private renderingDelayer: Delayer = new Delayer(200); + private renderingDelayer = this._register(new Delayer(200)); private readonly codeActions = new ResourceMap<[Range, languages.CodeAction[]][]>(uri => this.uriIdentityService.extUri.getComparisonKey(uri)); constructor( @@ -913,7 +913,7 @@ class WorkspaceConfigurationRenderer extends Disposable { private static readonly supportedKeys = ['folders', 'tasks', 'launch', 'extensions', 'settings', 'remoteAuthority', 'transient']; private readonly decorations: editorCommon.IEditorDecorationsCollection; - private renderingDelayer: Delayer = new Delayer(200); + private renderingDelayer = this._register(new Delayer(200)); constructor(private editor: ICodeEditor, private workspaceSettingsEditorModel: SettingsEditorModel, @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService, diff --git a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts index 0c8da5089e1..fc210a06396 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts @@ -271,14 +271,14 @@ export class SettingsEditor2 extends EditorPane { @IChatEntitlementService private readonly chatEntitlementService: IChatEntitlementService ) { super(SettingsEditor2.ID, group, telemetryService, themeService, storageService); - this.searchDelayer = new Delayer(200); + this.searchDelayer = this._register(new Delayer(200)); this.viewState = { settingsTarget: ConfigurationTarget.USER_LOCAL }; - this.settingFastUpdateDelayer = new Delayer(SettingsEditor2.SETTING_UPDATE_FAST_DEBOUNCE); - this.settingSlowUpdateDelayer = new Delayer(SettingsEditor2.SETTING_UPDATE_SLOW_DEBOUNCE); + this.settingFastUpdateDelayer = this._register(new Delayer(SettingsEditor2.SETTING_UPDATE_FAST_DEBOUNCE)); + this.settingSlowUpdateDelayer = this._register(new Delayer(SettingsEditor2.SETTING_UPDATE_SLOW_DEBOUNCE)); - this.searchInputDelayer = new Delayer(SettingsEditor2.SEARCH_DEBOUNCE); - this.updatedConfigSchemaDelayer = new Delayer(SettingsEditor2.CONFIG_SCHEMA_UPDATE_DELAYER); + this.searchInputDelayer = this._register(new Delayer(SettingsEditor2.SEARCH_DEBOUNCE)); + this.updatedConfigSchemaDelayer = this._register(new Delayer(SettingsEditor2.CONFIG_SCHEMA_UPDATE_DELAYER)); this.inSettingsEditorContextKey = CONTEXT_SETTINGS_EDITOR.bindTo(contextKeyService); this.searchFocusContextKey = CONTEXT_SETTINGS_SEARCH_FOCUS.bindTo(contextKeyService); diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts index 98d145ebf0f..530b0c4ae0f 100644 --- a/src/vs/workbench/contrib/remote/browser/remote.ts +++ b/src/vs/workbench/contrib/remote/browser/remote.ts @@ -525,7 +525,7 @@ class HelpPanelDescriptor implements IViewDescriptor { class RemoteViewPaneContainer extends FilterViewPaneContainer implements IViewModel { private helpPanelDescriptor = new HelpPanelDescriptor(this); helpInformation: HelpInformation[] = []; - private _onDidChangeHelpInformation = new Emitter(); + private _onDidChangeHelpInformation = this._register(new Emitter()); public onDidChangeHelpInformation: Event = this._onDidChangeHelpInformation.event; private hasRegisteredHelpView: boolean = false; private remoteSwitcher: SwitchRemoteViewItem | undefined; diff --git a/src/vs/workbench/contrib/scm/browser/menus.ts b/src/vs/workbench/contrib/scm/browser/menus.ts index 249ef2138ee..d783fd55814 100644 --- a/src/vs/workbench/contrib/scm/browser/menus.ts +++ b/src/vs/workbench/contrib/scm/browser/menus.ts @@ -29,12 +29,12 @@ export class SCMTitleMenu implements IDisposable { private _secondaryActions: IAction[] = []; get secondaryActions(): IAction[] { return this._secondaryActions; } - private readonly _onDidChangeTitle = new Emitter(); - readonly onDidChangeTitle = this._onDidChangeTitle.event; - readonly menu: IMenu; private readonly disposables = new DisposableStore(); + private readonly _onDidChangeTitle = this.disposables.add(new Emitter()); + readonly onDidChangeTitle = this._onDidChangeTitle.event; + constructor( @IMenuService menuService: IMenuService, @IContextKeyService contextKeyService: IContextKeyService diff --git a/src/vs/workbench/contrib/scm/browser/scmRepositoriesViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmRepositoriesViewPane.ts index d5c6b8459e5..1523a82cf18 100644 --- a/src/vs/workbench/contrib/scm/browser/scmRepositoriesViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmRepositoriesViewPane.ts @@ -883,6 +883,7 @@ export class SCMRepositoriesViewPane extends ViewPane { override dispose(): void { this.visibilityDisposables.dispose(); + this.repositoryDisposables.dispose(); super.dispose(); } } diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts index 012d3c545bd..669dd15c1c9 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts @@ -1698,6 +1698,7 @@ class SCMInputWidgetEditorOptions { dispose(): void { this._disposables.dispose(); + this._onDidChange.dispose(); } } @@ -3007,6 +3008,8 @@ export class SCMViewPane extends ViewPane { } override dispose(): void { + this._onDidChangeViewMode.dispose(); + this._onDidChangeViewSortKey.dispose(); this.visibilityDisposables.dispose(); this.disposables.dispose(); this.items.dispose(); diff --git a/src/vs/workbench/contrib/scm/browser/scmViewService.ts b/src/vs/workbench/contrib/scm/browser/scmViewService.ts index 114cfdc8c2e..d7b3583901c 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewService.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewService.ts @@ -593,6 +593,7 @@ export class SCMViewService implements ISCMViewService { dispose(): void { this.disposables.dispose(); + this._onDidFocusRepository.dispose(); this._onDidChangeRepositories.dispose(); this._onDidSetVisibleRepositories.dispose(); } diff --git a/src/vs/workbench/contrib/scm/common/scmService.ts b/src/vs/workbench/contrib/scm/common/scmService.ts index 8b6e1a13559..5bdf2e5f9aa 100644 --- a/src/vs/workbench/contrib/scm/common/scmService.ts +++ b/src/vs/workbench/contrib/scm/common/scmService.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Disposable, DisposableStore, toDisposable } from '../../../../base/common/lifecycle.js'; +import { Disposable, DisposableStore, IDisposable, toDisposable } from '../../../../base/common/lifecycle.js'; import { Event, Emitter } from '../../../../base/common/event.js'; import { ISCMService, ISCMProvider, ISCMInput, ISCMRepository, IInputValidator, ISCMInputChangeEvent, SCMInputChangeReason, InputValidationType, IInputValidation } from './scm.js'; import { ILogService } from '../../../../platform/log/common/log.js'; @@ -27,7 +27,7 @@ class SCMInput extends Disposable implements ISCMInput { return this._value; } - private readonly _onDidChange = new Emitter(); + private readonly _onDidChange = this._register(new Emitter()); readonly onDidChange: Event = this._onDidChange.event; private _placeholder = ''; @@ -41,7 +41,7 @@ class SCMInput extends Disposable implements ISCMInput { this._onDidChangePlaceholder.fire(placeholder); } - private readonly _onDidChangePlaceholder = new Emitter(); + private readonly _onDidChangePlaceholder = this._register(new Emitter()); readonly onDidChangePlaceholder: Event = this._onDidChangePlaceholder.event; private _enabled = true; @@ -55,7 +55,7 @@ class SCMInput extends Disposable implements ISCMInput { this._onDidChangeEnablement.fire(enabled); } - private readonly _onDidChangeEnablement = new Emitter(); + private readonly _onDidChangeEnablement = this._register(new Emitter()); readonly onDidChangeEnablement: Event = this._onDidChangeEnablement.event; private _visible = true; @@ -69,28 +69,28 @@ class SCMInput extends Disposable implements ISCMInput { this._onDidChangeVisibility.fire(visible); } - private readonly _onDidChangeVisibility = new Emitter(); + private readonly _onDidChangeVisibility = this._register(new Emitter()); readonly onDidChangeVisibility: Event = this._onDidChangeVisibility.event; setFocus(): void { this._onDidChangeFocus.fire(); } - private readonly _onDidChangeFocus = new Emitter(); + private readonly _onDidChangeFocus = this._register(new Emitter()); readonly onDidChangeFocus: Event = this._onDidChangeFocus.event; showValidationMessage(message: string | IMarkdownString, type: InputValidationType): void { this._onDidChangeValidationMessage.fire({ message: message, type: type }); } - private readonly _onDidChangeValidationMessage = new Emitter(); + private readonly _onDidChangeValidationMessage = this._register(new Emitter()); readonly onDidChangeValidationMessage: Event = this._onDidChangeValidationMessage.event; clearValidation(): void { this._onDidClearValidation.fire(); } - private readonly _onDidClearValidation = new Emitter(); + private readonly _onDidClearValidation = this._register(new Emitter()); readonly onDidClearValidation: Event = this._onDidClearValidation.event; private _validateInput: IInputValidator = () => Promise.resolve(undefined); @@ -104,7 +104,7 @@ class SCMInput extends Disposable implements ISCMInput { this._onDidChangeValidateInput.fire(); } - private readonly _onDidChangeValidateInput = new Emitter(); + private readonly _onDidChangeValidateInput = this._register(new Emitter()); readonly onDidChangeValidateInput: Event = this._onDidChangeValidateInput.event; private readonly historyNavigator: HistoryNavigator2; @@ -191,7 +191,7 @@ class SCMRepository implements ISCMRepository { private readonly _onDidChangeSelection = new Emitter(); readonly onDidChangeSelection: Event = this._onDidChangeSelection.event; - readonly input: ISCMInput; + readonly input: ISCMInput & IDisposable; constructor( public readonly id: string, @@ -213,6 +213,8 @@ class SCMRepository implements ISCMRepository { dispose(): void { this.disposables.dispose(); + this._onDidChangeSelection.dispose(); + this.input.dispose(); this.provider.dispose(); } } diff --git a/src/vs/workbench/contrib/scrollLocking/browser/scrollLocking.ts b/src/vs/workbench/contrib/scrollLocking/browser/scrollLocking.ts index 35b3076a111..ec64a54de06 100644 --- a/src/vs/workbench/contrib/scrollLocking/browser/scrollLocking.ts +++ b/src/vs/workbench/contrib/scrollLocking/browser/scrollLocking.ts @@ -23,7 +23,7 @@ export class SyncScroll extends Disposable implements IWorkbenchContribution { private readonly paneInitialScrollTop = new Map(); private readonly syncScrollDispoasbles = this._register(new DisposableStore()); - private readonly paneDisposables = new DisposableStore(); + private readonly paneDisposables = this._register(new DisposableStore()); private readonly statusBarEntry = this._register(new MutableDisposable()); diff --git a/src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchModel.ts b/src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchModel.ts index 6d5fe1e346a..ed24052b8cf 100644 --- a/src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchModel.ts +++ b/src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchModel.ts @@ -195,7 +195,7 @@ export class NotebookCompatibleFileMatch extends FileMatchImpl implements INoteb ) { super(_query, _previewOptions, _maxResults, _parent, rawMatch, _closestRoot, modelService, replaceService, labelService); this._cellMatches = new Map(); - this._notebookUpdateScheduler = new RunOnceScheduler(this.updateMatchesForEditorWidget.bind(this), 250); + this._notebookUpdateScheduler = this._register(new RunOnceScheduler(this.updateMatchesForEditorWidget.bind(this), 250)); } private _cellMatches: Map; public get cellContext(): Map> { diff --git a/src/vs/workbench/contrib/search/browser/searchTreeModel/fileMatch.ts b/src/vs/workbench/contrib/search/browser/searchTreeModel/fileMatch.ts index 7986616810d..7ac7a45def6 100644 --- a/src/vs/workbench/contrib/search/browser/searchTreeModel/fileMatch.ts +++ b/src/vs/workbench/contrib/search/browser/searchTreeModel/fileMatch.ts @@ -101,7 +101,7 @@ export class FileMatchImpl extends Disposable implements ISearchTreeFileMatch { this._resource = this.rawMatch.resource; this._textMatches = new Map(); this._removedTextMatches = new Set(); - this._updateScheduler = new RunOnceScheduler(this.updateMatchesForModel.bind(this), 250); + this._updateScheduler = this._register(new RunOnceScheduler(this.updateMatchesForModel.bind(this), 250)); this._name = new Lazy(() => labelService.getUriBasenameLabel(this.resource)); } diff --git a/src/vs/workbench/contrib/search/browser/searchWidget.ts b/src/vs/workbench/contrib/search/browser/searchWidget.ts index cfc48f507de..e9c0fcd4ae1 100644 --- a/src/vs/workbench/contrib/search/browser/searchWidget.ts +++ b/src/vs/workbench/contrib/search/browser/searchWidget.ts @@ -173,7 +173,7 @@ export class SearchWidget extends Widget { private _onDidHeightChange = this._register(new Emitter()); readonly onDidHeightChange: Event = this._onDidHeightChange.event; - private readonly _onDidToggleContext = new Emitter(); + private readonly _onDidToggleContext = this._register(new Emitter()); readonly onDidToggleContext: Event = this._onDidToggleContext.event; private showContextToggle!: Toggle; diff --git a/src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts b/src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts index 8e408accee9..1d4336a45d7 100644 --- a/src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts +++ b/src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts @@ -86,7 +86,7 @@ export class SearchEditor extends AbstractTextCodeEditor private toggleQueryDetailsButton!: HTMLElement; private messageBox!: HTMLElement; - private runSearchDelayer = new Delayer(0); + private runSearchDelayer = this._register(new Delayer(0)); private pauseSearching: boolean = false; private showingIncludesExcludes: boolean = false; private searchOperation: LongRunningOperation; @@ -125,7 +125,7 @@ export class SearchEditor extends AbstractTextCodeEditor this.searchOperation = this._register(new LongRunningOperation(progressService)); this._register(this.messageDisposables = new DisposableStore()); - this.searchHistoryDelayer = new Delayer(2000); + this.searchHistoryDelayer = this._register(new Delayer(2000)); this.searchModel = this._register(this.instantiationService.createInstance(SearchModelImpl)); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts b/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts index b3b306e07f8..1f06f04d3f0 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts @@ -19,6 +19,7 @@ import { getIconRegistry } from '../../../../platform/theme/common/iconRegistry. import { basename } from '../../../../base/common/path.js'; import { INotificationService, Severity } from '../../../../platform/notification/common/notification.js'; import { hasKey, isString } from '../../../../base/common/types.js'; +import { Event } from '../../../../base/common/event.js'; type DefaultProfileName = string; @@ -247,7 +248,9 @@ export class TerminalProfileQuickpick { run: () => r(false) }] ); - handle.onDidClose(() => r(false)); + Event.once(handle.onDidClose)(() => { + r(false); + }); }); } diff --git a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts index 838d17df872..96098673241 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts @@ -630,16 +630,16 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach } this._searchAddon = new AddonCtor({ highlightLimit: XtermTerminalConstants.SearchHighlightLimit }); this.raw.loadAddon(this._searchAddon); - this._searchAddon.onDidChangeResults((results: { resultIndex: number; resultCount: number }) => { + this._store.add(this._searchAddon.onDidChangeResults((results: { resultIndex: number; resultCount: number }) => { this._lastFindResult = results; this._onDidChangeFindResults.fire(results); - }); - this._searchAddon.onBeforeSearch(() => { + })); + this._store.add(this._searchAddon.onBeforeSearch(() => { this._onBeforeSearch.fire(); - }); - this._searchAddon.onAfterSearch(() => { + })); + this._store.add(this._searchAddon.onAfterSearch(() => { this._onAfterSearch.fire(); - }); + })); return this._searchAddon; }); } @@ -844,10 +844,10 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach try { this.raw.loadAddon(this._webglAddon); this._logService.trace('Webgl was loaded'); - this._webglAddon.onContextLoss(() => { + this._store.add(this._webglAddon.onContextLoss(() => { this._logService.info(`Webgl lost context, disposing of webgl renderer`); this._disposeOfWebglRenderer(); - }); + })); this._refreshImageAddon(); // WebGL renderer cell dimensions differ from the DOM renderer, make sure the terminal // gets resized after the webgl addon is loaded diff --git a/src/vs/workbench/contrib/terminalContrib/accessibility/browser/terminalAccessibleBufferProvider.ts b/src/vs/workbench/contrib/terminalContrib/accessibility/browser/terminalAccessibleBufferProvider.ts index 2796901804d..3f45c6281a8 100644 --- a/src/vs/workbench/contrib/terminalContrib/accessibility/browser/terminalAccessibleBufferProvider.ts +++ b/src/vs/workbench/contrib/terminalContrib/accessibility/browser/terminalAccessibleBufferProvider.ts @@ -21,7 +21,7 @@ export class TerminalAccessibleBufferProvider extends Disposable implements IAcc private _focusedInstance: ITerminalInstance | undefined; - private readonly _onDidRequestClearProvider = new Emitter(); + private readonly _onDidRequestClearProvider = this._register(new Emitter()); readonly onDidRequestClearLastProvider = this._onDidRequestClearProvider.event; constructor( diff --git a/src/vs/workbench/contrib/terminalContrib/links/browser/terminal.links.contribution.ts b/src/vs/workbench/contrib/terminalContrib/links/browser/terminal.links.contribution.ts index bee79eabe20..bdea55b6466 100644 --- a/src/vs/workbench/contrib/terminalContrib/links/browser/terminal.links.contribution.ts +++ b/src/vs/workbench/contrib/terminalContrib/links/browser/terminal.links.contribution.ts @@ -83,9 +83,9 @@ class TerminalLinkContribution extends DisposableStore implements ITerminalContr async showLinkQuickpick(extended?: boolean): Promise { if (!this._terminalLinkQuickpick) { this._terminalLinkQuickpick = this.add(this._instantiationService.createInstance(TerminalLinkQuickpick)); - this._terminalLinkQuickpick.onDidRequestMoreLinks(() => { + this.add(this._terminalLinkQuickpick.onDidRequestMoreLinks(() => { this.showLinkQuickpick(true); - }); + })); } const links = await this._getLinks(); return await this._terminalLinkQuickpick.show(this._ctx.instance, links); diff --git a/src/vs/workbench/contrib/terminalContrib/quickFix/browser/quickFixAddon.ts b/src/vs/workbench/contrib/terminalContrib/quickFix/browser/quickFixAddon.ts index 06dd0578137..c34b5dece25 100644 --- a/src/vs/workbench/contrib/terminalContrib/quickFix/browser/quickFixAddon.ts +++ b/src/vs/workbench/contrib/terminalContrib/quickFix/browser/quickFixAddon.ts @@ -76,9 +76,9 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon, private _didRun: boolean = false; - private readonly _onDidRequestRerunCommand = new Emitter<{ command: string; shouldExecute?: boolean }>(); + private readonly _onDidRequestRerunCommand = this._register(new Emitter<{ command: string; shouldExecute?: boolean }>()); readonly onDidRequestRerunCommand = this._onDidRequestRerunCommand.event; - private readonly _onDidUpdateQuickFixes = new Emitter<{ command: ITerminalCommand; actions: ITerminalAction[] | undefined }>(); + private readonly _onDidUpdateQuickFixes = this._register(new Emitter<{ command: ITerminalCommand; actions: ITerminalAction[] | undefined }>()); readonly onDidUpdateQuickFixes = this._onDidUpdateQuickFixes.event; constructor( diff --git a/src/vs/workbench/contrib/terminalContrib/typeAhead/browser/terminalTypeAheadAddon.ts b/src/vs/workbench/contrib/terminalContrib/typeAhead/browser/terminalTypeAheadAddon.ts index 25f126cdd8a..66b343c5574 100644 --- a/src/vs/workbench/contrib/terminalContrib/typeAhead/browser/terminalTypeAheadAddon.ts +++ b/src/vs/workbench/contrib/terminalContrib/typeAhead/browser/terminalTypeAheadAddon.ts @@ -648,7 +648,7 @@ export class PredictionStats extends Disposable { private readonly _stats: [latency: number, correct: boolean][] = []; private _index = 0; private readonly _addedAtTime = new WeakMap(); - private readonly _changeEmitter = new Emitter(); + private readonly _changeEmitter = this._register(new Emitter()); readonly onChange = this._changeEmitter.event; /** diff --git a/src/vs/workbench/contrib/testing/browser/explorerProjections/listProjection.ts b/src/vs/workbench/contrib/testing/browser/explorerProjections/listProjection.ts index 468121c4c1d..8e3fca051d8 100644 --- a/src/vs/workbench/contrib/testing/browser/explorerProjections/listProjection.ts +++ b/src/vs/workbench/contrib/testing/browser/explorerProjections/listProjection.ts @@ -65,7 +65,7 @@ class ListTestItemElement extends TestItemTreeElement { * Projection that lists tests in their traditional tree view. */ export class ListProjection extends Disposable implements ITestTreeProjection { - private readonly updateEmitter = new Emitter(); + private readonly updateEmitter = this._register(new Emitter()); private readonly items = new Map(); /** diff --git a/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.ts b/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.ts index 054bc7bf954..c97c256c9d6 100644 --- a/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.ts +++ b/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.ts @@ -96,7 +96,7 @@ class TreeTestItemElement extends TestItemTreeElement { * Projection that lists tests in their traditional tree view. */ export class TreeProjection extends Disposable implements ITestTreeProjection { - private readonly updateEmitter = new Emitter(); + private readonly updateEmitter = this._register(new Emitter()); private readonly changedParents = new Set(); private readonly resortedParents = new Set(); diff --git a/src/vs/workbench/contrib/testing/browser/testingDecorations.ts b/src/vs/workbench/contrib/testing/browser/testingDecorations.ts index 0cda4a7ac35..50bd28bca26 100644 --- a/src/vs/workbench/contrib/testing/browser/testingDecorations.ts +++ b/src/vs/workbench/contrib/testing/browser/testingDecorations.ts @@ -126,7 +126,7 @@ export class TestingDecorationService extends Disposable implements ITestingDeco declare public _serviceBrand: undefined; private generation = 0; - private readonly changeEmitter = new Emitter(); + private readonly changeEmitter = this._register(new Emitter()); private readonly decorationCache = new ResourceMap<{ /** The document version at which ranges have been updated, requiring rerendering */ rangeUpdateVersionId?: number; diff --git a/src/vs/workbench/contrib/testing/common/testExplorerFilterState.ts b/src/vs/workbench/contrib/testing/common/testExplorerFilterState.ts index 9c187e33e76..b1b5b41edd8 100644 --- a/src/vs/workbench/contrib/testing/common/testExplorerFilterState.ts +++ b/src/vs/workbench/contrib/testing/common/testExplorerFilterState.ts @@ -80,7 +80,7 @@ const trimExtraWhitespace = (str: string) => str.replace(/\s\s+/g, ' ').trim(); export class TestExplorerFilterState extends Disposable implements ITestExplorerFilterState { declare _serviceBrand: undefined; - private readonly focusEmitter = new Emitter(); + private readonly focusEmitter = this._register(new Emitter()); /** * Mapping of terms to whether they're included in the text. */ diff --git a/src/vs/workbench/contrib/testing/common/testResultService.ts b/src/vs/workbench/contrib/testing/common/testResultService.ts index 8790f01262f..87c3210aeff 100644 --- a/src/vs/workbench/contrib/testing/common/testResultService.ts +++ b/src/vs/workbench/contrib/testing/common/testResultService.ts @@ -106,7 +106,7 @@ export class TestResultService extends Disposable implements ITestResultService } })); - protected readonly persistScheduler = new RunOnceScheduler(() => this.persistImmediately(), 500); + protected readonly persistScheduler = this._register(new RunOnceScheduler(() => this.persistImmediately(), 500)); constructor( @IContextKeyService contextKeyService: IContextKeyService, diff --git a/src/vs/workbench/contrib/testing/common/testServiceImpl.ts b/src/vs/workbench/contrib/testing/common/testServiceImpl.ts index 5ff7b8c97ac..f731239870f 100644 --- a/src/vs/workbench/contrib/testing/common/testServiceImpl.ts +++ b/src/vs/workbench/contrib/testing/common/testServiceImpl.ts @@ -41,9 +41,9 @@ export class TestService extends Disposable implements ITestService { private testControllers = observableValue>('testControllers', new Map()); private testExtHosts = new Set(); - private readonly cancelExtensionTestRunEmitter = new Emitter<{ runId: string | undefined; taskId: string | undefined }>(); - private readonly willProcessDiffEmitter = new Emitter(); - private readonly didProcessDiffEmitter = new Emitter(); + private readonly cancelExtensionTestRunEmitter = this._register(new Emitter<{ runId: string | undefined; taskId: string | undefined }>()); + private readonly willProcessDiffEmitter = this._register(new Emitter()); + private readonly didProcessDiffEmitter = this._register(new Emitter()); private readonly testRefreshCancellations = new Set(); private readonly isRefreshingTests: IContextKey; private readonly activeEditorHasTests: IContextKey; diff --git a/src/vs/workbench/contrib/testing/common/testingContinuousRunService.ts b/src/vs/workbench/contrib/testing/common/testingContinuousRunService.ts index ccb27d63e7a..866aee01e9f 100644 --- a/src/vs/workbench/contrib/testing/common/testingContinuousRunService.ts +++ b/src/vs/workbench/contrib/testing/common/testingContinuousRunService.ts @@ -86,7 +86,7 @@ type RunningRef = { path: readonly string[]; profiles: ISettableObservable(); + private readonly changeEmitter = this._register(new Emitter()); private readonly running = new WellDefinedPrefixTree(); private readonly lastRun: StoredValue>; diff --git a/src/vs/workbench/contrib/timeline/browser/timelinePane.ts b/src/vs/workbench/contrib/timeline/browser/timelinePane.ts index efca4183366..c7c9cc7f99b 100644 --- a/src/vs/workbench/contrib/timeline/browser/timelinePane.ts +++ b/src/vs/workbench/contrib/timeline/browser/timelinePane.ts @@ -926,7 +926,7 @@ export class TimelinePane extends ViewPane { // this.treeElement.classList.add('show-file-icons'); container.appendChild(this.$tree); - this.treeRenderer = this.instantiationService.createInstance(TimelineTreeRenderer, this.commands, this.viewDescriptorService.getViewLocationById(this.id)); + this.treeRenderer = this._register(this.instantiationService.createInstance(TimelineTreeRenderer, this.commands, this.viewDescriptorService.getViewLocationById(this.id))); this._register(this.treeRenderer.onDidScrollToEnd(item => { if (this.pageOnScroll) { this.loadMore(item); @@ -1153,8 +1153,8 @@ export class TimelineListVirtualDelegate implements IListVirtualDelegate { - private readonly _onDidScrollToEnd = new Emitter(); +class TimelineTreeRenderer extends Disposable implements ITreeRenderer { + private readonly _onDidScrollToEnd = this._register(new Emitter()); readonly onDidScrollToEnd: Event = this._onDidScrollToEnd.event; readonly templateId: string = TimelineElementTemplate.id; @@ -1169,6 +1169,7 @@ class TimelineTreeRenderer implements ITreeRenderer { this.gettingStartedCategories = this.gettingStartedService.getWalkthroughs(); diff --git a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedList.ts b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedList.ts index e3213ed92d9..0ffdd5159ed 100644 --- a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedList.ts +++ b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedList.ts @@ -23,7 +23,7 @@ type GettingStartedIndexListOptions = { }; export class GettingStartedIndexList extends Disposable { - private readonly _onDidChangeEntries = new Emitter(); + private readonly _onDidChangeEntries = this._register(new Emitter()); private readonly onDidChangeEntries: Event = this._onDidChangeEntries.event; private domElement: HTMLElement; diff --git a/src/vs/workbench/services/search/browser/searchService.ts b/src/vs/workbench/services/search/browser/searchService.ts index c9011956dbb..6d047cba7f1 100644 --- a/src/vs/workbench/services/search/browser/searchService.ts +++ b/src/vs/workbench/services/search/browser/searchService.ts @@ -51,7 +51,7 @@ export class LocalFileSearchWorkerClient extends Disposable implements ISearchRe protected _worker: IWebWorkerClient | null; - private readonly _onDidReceiveTextSearchMatch = new Emitter<{ match: IFileMatch; queryId: number }>(); + private readonly _onDidReceiveTextSearchMatch = this._register(new Emitter<{ match: IFileMatch; queryId: number }>()); readonly onDidReceiveTextSearchMatch: Event<{ match: IFileMatch; queryId: number }> = this._onDidReceiveTextSearchMatch.event; private cache: { key: string; cache: ISearchComplete } | undefined; diff --git a/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateWorkerTokenizer.ts b/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateWorkerTokenizer.ts index 6b5bc990d72..f031be8574d 100644 --- a/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateWorkerTokenizer.ts +++ b/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateWorkerTokenizer.ts @@ -55,6 +55,7 @@ export class TextMateWorkerTokenizer extends MirrorTextModel { public override dispose(): void { this._isDisposed = true; + this._tokenizeDebouncer.dispose(); super.dispose(); } diff --git a/src/vs/workbench/services/themes/common/themeExtensionPoints.ts b/src/vs/workbench/services/themes/common/themeExtensionPoints.ts index 028e88c2a29..aa8af78316c 100644 --- a/src/vs/workbench/services/themes/common/themeExtensionPoints.ts +++ b/src/vs/workbench/services/themes/common/themeExtensionPoints.ts @@ -185,6 +185,7 @@ export class ThemeRegistry implements IDisposable { dispose() { this.themesExtPoint.setHandler(() => { }); + this.onDidChangeEmitter.dispose(); } private initialize() {