diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/breakpoints/notebookBreakpoints.ts b/src/vs/workbench/contrib/notebook/browser/contrib/breakpoints/notebookBreakpoints.ts index b292a5bcbf296..4610dde5ac23b 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/breakpoints/notebookBreakpoints.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/breakpoints/notebookBreakpoints.ts @@ -181,11 +181,13 @@ class NotebookCellPausing extends Disposable implements IWorkbenchContribution { internalMetadata.didPause = true; } - notebookModel?.applyEdits([{ - editType: CellEditType.PartialInternalMetadata, - handle: parsed.handle, - internalMetadata, - }], true, undefined, () => undefined, undefined); + if (notebookModel?.checkCellExistence(parsed.handle)) { + notebookModel?.applyEdits([{ + editType: CellEditType.PartialInternalMetadata, + handle: parsed.handle, + internalMetadata, + }], true, undefined, () => undefined, undefined); + } } } } diff --git a/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts b/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts index af4a1525fbd2e..c6ebc80fc3636 100644 --- a/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts +++ b/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts @@ -381,6 +381,10 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel return this.cells.findIndex(c => !!c.outputs.find(o => o.outputId === outputId)); } + checkCellExistence(handle: number) { + return this._cellListeners.has(handle); + } + reset(cells: ICellDto2[], metadata: NotebookDocumentMetadata, transientOptions: TransientOptions): void { this.transientOptions = transientOptions; this._cellhandlePool = 0;