diff --git a/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts b/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts index 1f0f7990622..72a6fac7b31 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; }