diff --git a/src/vs/editor/contrib/suggest/suggestController.ts b/src/vs/editor/contrib/suggest/suggestController.ts index 32c77163d8b..3fd85e6138a 100644 --- a/src/vs/editor/contrib/suggest/suggestController.ts +++ b/src/vs/editor/contrib/suggest/suggestController.ts @@ -139,7 +139,7 @@ export class SuggestController implements IEditorContribution { const { acceptSuggestionOnEnter } = this._editor.getConfiguration().contribInfo; acceptSuggestionsOnEnter.set(acceptSuggestionOnEnter === 'on' || acceptSuggestionOnEnter === 'smart'); }; - this._toDispose.add(this._editor.onDidChangeConfiguration((e) => updateFromConfig())); + this._toDispose.add(this._editor.onDidChangeConfiguration(() => updateFromConfig())); updateFromConfig(); } @@ -151,9 +151,7 @@ export class SuggestController implements IEditorContribution { dispose(): void { this._toDispose.dispose(); this._widget.dispose(); - if (this._model) { - this._model.dispose(); - } + this._model.dispose(); } protected _insertSuggestion(event: ISelectedSuggestion | undefined, keepAlternativeSuggestions: boolean, undoStops: boolean): void { diff --git a/src/vs/workbench/api/common/extHostDocuments.ts b/src/vs/workbench/api/common/extHostDocuments.ts index b7cf7793138..fc8bc68cb40 100644 --- a/src/vs/workbench/api/common/extHostDocuments.ts +++ b/src/vs/workbench/api/common/extHostDocuments.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { Emitter, Event } from 'vs/base/common/event'; -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { DisposableStore } from 'vs/base/common/lifecycle'; import { URI, UriComponents } from 'vs/base/common/uri'; import { IModelChangedEvent } from 'vs/editor/common/model/mirrorTextModel'; import { ExtHostDocumentsShape, IMainContext, MainContext, MainThreadDocumentsShape } from 'vs/workbench/api/common/extHost.protocol'; @@ -25,7 +25,7 @@ export class ExtHostDocuments implements ExtHostDocumentsShape { readonly onDidChangeDocument: Event = this._onDidChangeDocument.event; readonly onDidSaveDocument: Event = this._onDidSaveDocument.event; - private _toDispose: IDisposable[]; + private readonly _toDispose = new DisposableStore(); private _proxy: MainThreadDocumentsShape; private _documentsAndEditors: ExtHostDocumentsAndEditors; private _documentLoader = new Map>(); @@ -34,22 +34,20 @@ export class ExtHostDocuments implements ExtHostDocumentsShape { this._proxy = mainContext.getProxy(MainContext.MainThreadDocuments); this._documentsAndEditors = documentsAndEditors; - this._toDispose = [ - this._documentsAndEditors.onDidRemoveDocuments(documents => { - for (const data of documents) { - this._onDidRemoveDocument.fire(data.document); - } - }), - this._documentsAndEditors.onDidAddDocuments(documents => { - for (const data of documents) { - this._onDidAddDocument.fire(data.document); - } - }) - ]; + this._documentsAndEditors.onDidRemoveDocuments(documents => { + for (const data of documents) { + this._onDidRemoveDocument.fire(data.document); + } + }, undefined, this._toDispose); + this._documentsAndEditors.onDidAddDocuments(documents => { + for (const data of documents) { + this._onDidAddDocument.fire(data.document); + } + }, undefined, this._toDispose); } public dispose(): void { - dispose(this._toDispose); + this._toDispose.dispose(); } public getAllDocumentData(): ExtHostDocumentData[] {