minimum scrolling to reveal the next cell on shift+enter (#183600)

do minimum scrolling to reveal the next cell on Execute cell and select next
This commit is contained in:
Aaron Munger 2023-05-26 14:30:46 -07:00 committed by GitHub
parent 354fb8fafa
commit 397175e067
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View file

@ -456,12 +456,12 @@ registerAction2(class ExecuteCellSelectBelow extends NotebookCellAction {
const nextCell = context.notebookEditor.cellAt(idx + 1);
context.cell.updateEditState(CellEditState.Preview, EXECUTE_CELL_SELECT_BELOW);
if (nextCell) {
await context.notebookEditor.focusNotebookCell(nextCell, 'container');
await context.notebookEditor.focusNotebookCell(nextCell, 'container', { minimalScrolling: true });
} else {
const newCell = insertCell(languageService, context.notebookEditor, idx, CellKind.Markup, 'below');
if (newCell) {
await context.notebookEditor.focusNotebookCell(newCell, 'editor');
await context.notebookEditor.focusNotebookCell(newCell, 'editor', { minimalScrolling: true });
}
}
return;
@ -469,12 +469,12 @@ registerAction2(class ExecuteCellSelectBelow extends NotebookCellAction {
// Try to select below, fall back on inserting
const nextCell = context.notebookEditor.cellAt(idx + 1);
if (nextCell) {
await context.notebookEditor.focusNotebookCell(nextCell, 'container');
await context.notebookEditor.focusNotebookCell(nextCell, 'container', { minimalScrolling: true });
} else {
const newCell = insertCell(languageService, context.notebookEditor, idx, CellKind.Code, 'below');
if (newCell) {
await context.notebookEditor.focusNotebookCell(newCell, 'editor');
await context.notebookEditor.focusNotebookCell(newCell, 'editor', { minimalScrolling: true });
}
}

View file

@ -150,6 +150,7 @@ export interface ICommonCellInfo {
export interface IFocusNotebookCellOptions {
readonly skipReveal?: boolean;
readonly focusEditorLine?: number;
readonly minimalScrolling?: boolean;
}
//#endregion

View file

@ -2352,6 +2352,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
if (typeof options?.focusEditorLine === 'number') {
this._cursorNavMode.set(true);
this.revealInView(cell);
} else if (options?.minimalScrolling) {
this.revealInView(cell);
} else {
this.revealInCenterIfOutsideViewport(cell);
}