diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts index 25020d7976467a..6cc0283607fe2a 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts @@ -273,6 +273,11 @@ export class FindModel extends Disposable { private async revealCellRange(cellIndex: number, matchIndex: number, outputOffset: number | null) { const findMatch = this._findMatches[cellIndex]; + // _findMatches can be replaced between cellIndex computation and this + // async execution (e.g. via research() triggered by onDidChangeContent). + if (!findMatch) { + return; + } if (matchIndex >= findMatch.contentMatches.length) { // reveal output range this._notebookEditor.focusElement(findMatch.cell);