no more need to dispose ExtHostCell

This commit is contained in:
Johannes Rieken
2021-04-15 13:59:16 +02:00
parent f1d0c30f1e
commit 6f9917d81f

View File

@@ -3,8 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Emitter, Event } from 'vs/base/common/event';
import { Disposable, DisposableStore, dispose } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import { deepFreeze, equals } from 'vs/base/common/objects';
import { URI } from 'vs/base/common/uri';
@@ -46,9 +44,6 @@ export class ExtHostCell {
};
}
private _onDidDispose = new Emitter<void>();
readonly onDidDispose: Event<void> = this._onDidDispose.event;
private _outputs: extHostTypes.NotebookCellOutput[];
private _metadata: extHostTypes.NotebookCellMetadata;
private _previousResult: vscode.NotebookCellExecutionSummary | undefined;
@@ -74,11 +69,6 @@ export class ExtHostCell {
this._previousResult = extHostTypeConverters.NotebookCellPreviousExecutionResult.to(this._internalMetadata);
}
dispose() {
this._onDidDispose.fire();
this._onDidDispose.dispose();
}
get internalMetadata(): NotebookCellMetadata {
return this._internalMetadata;
}
@@ -133,15 +123,13 @@ export interface INotebookEventEmitter {
}
export class ExtHostNotebookDocument extends Disposable {
export class ExtHostNotebookDocument {
private static _handlePool: number = 0;
readonly handle = ExtHostNotebookDocument._handlePool++;
private _cells: ExtHostCell[] = [];
private _cellDisposableMapping = new Map<number, DisposableStore>();
private _notebook: vscode.NotebookDocument | undefined;
private _versionId: number = 0;
private _isDirty: boolean = false;
@@ -156,17 +144,12 @@ export class ExtHostNotebookDocument extends Disposable {
private readonly _viewType: string,
private _metadata: extHostTypes.NotebookDocumentMetadata,
readonly uri: URI,
) {
super();
}
) { }
override dispose() {
dispose() {
this._disposed = true;
super.dispose();
dispose(this._cellDisposableMapping.values());
}
get notebookDocument(): vscode.NotebookDocument {
if (!this._notebook) {
const that = this;
@@ -285,25 +268,12 @@ export class ExtHostNotebookDocument extends Disposable {
const newCells = cellDtos.map(cell => {
const extCell = new ExtHostCell(this, this._textDocumentsAndEditors, cell);
if (!initialization) {
addedCellDocuments.push(ExtHostCell.asModelAddData(this.notebookDocument, cell));
}
if (!this._cellDisposableMapping.has(extCell.handle)) {
const store = new DisposableStore();
store.add(extCell);
this._cellDisposableMapping.set(extCell.handle, store);
}
return extCell;
});
for (let j = splice[0]; j < splice[0] + splice[1]; j++) {
this._cellDisposableMapping.get(this._cells[j].handle)?.dispose();
this._cellDisposableMapping.delete(this._cells[j].handle);
}
const changeEvent = new RawContentChangeEvent(splice[0], splice[1], [], newCells);
const deletedItems = this._cells.splice(splice[0], splice[1], ...newCells);
for (let cell of deletedItems) {