From 4b50b99ca53f294c91270da516a9c6859ca477e6 Mon Sep 17 00:00:00 2001 From: Ali Ahmadi Date: Mon, 8 Jun 2026 15:53:13 +0330 Subject: [PATCH] fix: guard against race condition in notebook find revealCellRange (#225578) When find matches are being revealed and the underlying _findMatches array is replaced between the cellIndex computation and the async callback (e.g. via research() triggered by onDidChangeContent), findMatch can be undefined. Add an early return guard to prevent 'Cannot read properties of undefined (reading contentMatches)'. Fixes #225578 --- .../contrib/notebook/browser/contrib/find/findModel.ts | 5 +++++ 1 file changed, 5 insertions(+) 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 25020d7976467..6cc0283607fe2 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);