From dc88b6108c6706f88e1591e922f3a856bdda92ee Mon Sep 17 00:00:00 2001 From: Dinesh Chandnani Date: Tue, 4 Nov 2025 23:15:19 -0800 Subject: [PATCH 1/2] Fix for cell scrolling on F3 #275247 --- .../notebook/browser/contrib/find/findModel.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 7858fef22dc..6181daa056c 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts @@ -220,8 +220,8 @@ export class FindModel extends Disposable { const matchesBefore = findMatchIndex === 0 ? 0 : (this._findMatchesStarts?.getPrefixSum(findMatchIndex - 1) ?? 0); this._currentMatch = matchesBefore + index; - this.highlightCurrentFindMatchDecoration(findMatchIndex, index).then(offset => { - this.revealCellRange(findMatchIndex, index, offset); + this.highlightCurrentFindMatchDecoration(findMatchIndex, index).then(async offset => { + await this.revealCellRange(findMatchIndex, index, offset); this._state.changeMatchInfo( this._currentMatch, @@ -259,8 +259,8 @@ export class FindModel extends Disposable { const nextIndex = this._findMatchesStarts!.getIndexOf(this._currentMatch); // const newFocusedCell = this._findMatches[nextIndex.index].cell; - this.highlightCurrentFindMatchDecoration(nextIndex.index, nextIndex.remainder).then(offset => { - this.revealCellRange(nextIndex.index, nextIndex.remainder, offset); + this.highlightCurrentFindMatchDecoration(nextIndex.index, nextIndex.remainder).then(async offset => { + await this.revealCellRange(nextIndex.index, nextIndex.remainder, offset); this._state.changeMatchInfo( this._currentMatch, @@ -270,7 +270,7 @@ export class FindModel extends Disposable { }); } - private revealCellRange(cellIndex: number, matchIndex: number, outputOffset: number | null) { + private async revealCellRange(cellIndex: number, matchIndex: number, outputOffset: number | null) { const findMatch = this._findMatches[cellIndex]; if (matchIndex >= findMatch.contentMatches.length) { // reveal output range @@ -288,6 +288,9 @@ export class FindModel extends Disposable { findMatch.cell.isInputCollapsed = false; this._notebookEditor.focusElement(findMatch.cell); this._notebookEditor.setCellEditorSelection(findMatch.cell, match.range); + // First ensure the cell is visible in the notebook viewport with minimal scrolling + await this._notebookEditor.revealInView(findMatch.cell); + // Then reveal the specific range within the cell editor this._notebookEditor.revealRangeInCenterIfOutsideViewportAsync(findMatch.cell, match.range); } } From e1c83d3dabc95043114ce934262d880a34f61cb5 Mon Sep 17 00:00:00 2001 From: Dinesh Chandnani Date: Wed, 5 Nov 2025 00:02:57 -0800 Subject: [PATCH 2/2] Fixed the test for this update --- .../contrib/notebook/browser/contrib/find/findModel.ts | 2 +- .../contrib/notebook/test/browser/testNotebookEditor.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 6181daa056c..072ba66abf4 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts @@ -288,7 +288,7 @@ export class FindModel extends Disposable { findMatch.cell.isInputCollapsed = false; this._notebookEditor.focusElement(findMatch.cell); this._notebookEditor.setCellEditorSelection(findMatch.cell, match.range); - // First ensure the cell is visible in the notebook viewport with minimal scrolling + // First ensure the cell is visible in the notebook viewport await this._notebookEditor.revealInView(findMatch.cell); // Then reveal the specific range within the cell editor this._notebookEditor.revealRangeInCenterIfOutsideViewportAsync(findMatch.cell, match.range); diff --git a/src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts b/src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts index 8731f5e2c3f..e421996c3f2 100644 --- a/src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts @@ -313,6 +313,7 @@ function _createTestNotebookEditor(instantiationService: TestInstantiationServic override getViewIndexByModelIndex(index: number) { return listViewInfoAccessor.getViewIndex(viewModel.viewCells[index]); } override getCellRangeFromViewRange(startIndex: number, endIndex: number) { return listViewInfoAccessor.getCellRangeFromViewRange(startIndex, endIndex); } override revealCellRangeInView() { } + override async revealInView() { } override setHiddenAreas(_ranges: ICellRange[]): boolean { return cellList.setHiddenAreas(_ranges, true); }