Merge pull request #275485 from microsoft/dineshc/notebookf3-fix

Fix for cell scrolling on F3 #275247
This commit is contained in:
Peng Lyu
2025-11-06 11:49:39 -08:00
committed by GitHub
2 changed files with 9 additions and 5 deletions
@@ -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
await this._notebookEditor.revealInView(findMatch.cell);
// Then reveal the specific range within the cell editor
this._notebookEditor.revealRangeInCenterIfOutsideViewportAsync(findMatch.cell, match.range);
}
}
@@ -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);
}