diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts index 7a52587d2c9..629c790293e 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts @@ -19,6 +19,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IResolvedTextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService'; import { ViewContext } from 'vs/workbench/contrib/notebook/browser/viewModel/viewContext'; import { Mimes } from 'vs/base/common/mime'; +import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo'; export abstract class BaseCellViewModel extends Disposable { @@ -150,6 +151,7 @@ export abstract class BaseCellViewModel extends Disposable { private readonly _viewContext: ViewContext, private readonly _configurationService: IConfigurationService, private readonly _modelService: ITextModelService, + private readonly _undoRedoService: IUndoRedoService ) { super(); @@ -538,6 +540,8 @@ export abstract class BaseCellViewModel extends Disposable { override dispose() { super.dispose(); + this._undoRedoService.removeElements(this.uri); + if (this._textModelRef) { this._textModelRef.dispose(); } diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts index 5ea32f42f26..1c8db996198 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts @@ -9,6 +9,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo'; import { CellEditState, CellFindMatch, CodeCellLayoutChangeEvent, CodeCellLayoutInfo, CodeCellLayoutState, ICellOutputViewModel, ICellViewModel, NotebookLayoutInfo } from 'vs/workbench/contrib/notebook/browser/notebookBrowser'; import { CellOutputViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel'; import { ViewContext } from 'vs/workbench/contrib/notebook/browser/viewModel/viewContext'; @@ -103,8 +104,9 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod @IConfigurationService configurationService: IConfigurationService, @INotebookService private readonly _notebookService: INotebookService, @ITextModelService modelService: ITextModelService, + @IUndoRedoService undoRedoService: IUndoRedoService ) { - super(viewType, model, UUID.generateUuid(), viewContext, configurationService, modelService); + super(viewType, model, UUID.generateUuid(), viewContext, configurationService, modelService, undoRedoService); this._outputViewModels = this.model.outputs.map(output => new CellOutputViewModel(this, output, this._notebookService)); this._register(this.model.onDidChangeOutputs((splice) => { diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.ts index 799e7a2e786..3989cd96268 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.ts @@ -16,6 +16,7 @@ import { CellKind, INotebookSearchOptions } from 'vs/workbench/contrib/notebook/ import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { ViewContext } from 'vs/workbench/contrib/notebook/browser/viewModel/viewContext'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo'; export class MarkupCellViewModel extends BaseCellViewModel implements ICellViewModel { @@ -114,8 +115,9 @@ export class MarkupCellViewModel extends BaseCellViewModel implements ICellViewM @IConfigurationService configurationService: IConfigurationService, @ITextModelService textModelService: ITextModelService, @IInstantiationService instantiationService: IInstantiationService, + @IUndoRedoService undoRedoService: IUndoRedoService ) { - super(viewType, model, UUID.generateUuid(), viewContext, configurationService, textModelService); + super(viewType, model, UUID.generateUuid(), viewContext, configurationService, textModelService, undoRedoService); const { bottomToolbarGap } = this.viewContext.notebookOptions.computeBottomToolbarDimensions(this.viewType);