diff --git a/src/vs/workbench/api/browser/mainThreadComments.ts b/src/vs/workbench/api/browser/mainThreadComments.ts index 55965f6e58c..43bcbaa54e0 100644 --- a/src/vs/workbench/api/browser/mainThreadComments.ts +++ b/src/vs/workbench/api/browser/mainThreadComments.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { Disposable, IDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle'; import { ICodeEditor, isCodeEditor, isDiffEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser'; import * as modes from 'vs/editor/common/modes'; import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; @@ -473,10 +473,12 @@ export class MainThreadComments extends Disposable implements MainThreadComments private _commentControllers = new Map(); private _activeCommentThread?: MainThreadCommentThread; + private readonly _activeCommentThreadDisposables = this._register(new DisposableStore()); private _input?: modes.CommentInput; private _openPanelListener: IDisposable | null; + constructor( extHostContext: IExtHostContext, @IEditorService private readonly _editorService: IEditorService, @@ -488,7 +490,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments super(); this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostComments); - this._disposables.push(this._commentService.onDidChangeActiveCommentThread(async thread => { + this._register(this._commentService.onDidChangeActiveCommentThread(async thread => { let handle = (thread as MainThreadCommentThread).controllerHandle; let controller = this._commentControllers.get(handle); @@ -496,11 +498,11 @@ export class MainThreadComments extends Disposable implements MainThreadComments return; } - this._activeCommentThreadDisposables = dispose(this._activeCommentThreadDisposables); + this._activeCommentThreadDisposables.clear(); this._activeCommentThread = thread as MainThreadCommentThread; controller.activeCommentThread = this._activeCommentThread; - this._activeCommentThreadDisposables.push(this._activeCommentThread.onDidChangeInput(input => { // todo, dispose + this._activeCommentThreadDisposables.add(this._activeCommentThread.onDidChangeInput(input => { // todo, dispose this._input = input; this._proxy.$onCommentWidgetInputChange(handle, URI.parse(this._activeCommentThread!.resource), this._activeCommentThread!.range, this._input ? this._input.value : undefined); }));