diff --git a/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts b/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts index 1f0f7990622a596075a1486fcc63fa3e7983654d..72a6fac7b31992541193d17e1e6aee57e5d48a16 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts @@ -534,7 +534,11 @@ export class NotebookCellList extends WorkbenchList implements ID private _getViewIndexUpperBound(cell: ICellViewModel): number { - const modelIndex = this._viewModel!.getCellIndex(cell); + if (!this._viewModel) { + return -1; + } + + const modelIndex = this._viewModel.getCellIndex(cell); if (!this.hiddenRangesPrefixSum) { return modelIndex; }