Focus cell when executed via UI

Fix #143268
pull/143482/head
Rob Lourens 2022-02-18 21:38:41 -08:00
parent 388925f588
commit 726f9c95da
1 changed files with 7 additions and 0 deletions

View File

@ -193,6 +193,10 @@ registerAction2(class ExecuteCell extends NotebookMultiCellAction {
}
async runWithContext(accessor: ServicesAccessor, context: INotebookCommandContext | INotebookCellToolbarActionContext): Promise<void> {
if (context.ui) {
context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
}
return runCell(accessor, context);
}
});
@ -231,6 +235,7 @@ registerAction2(class ExecuteAboveCells extends NotebookMultiCellAction {
let endCellIdx: number | undefined = undefined;
if (context.ui) {
endCellIdx = context.notebookEditor.getCellIndex(context.cell);
context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
} else {
endCellIdx = Math.min(...context.selectedCells.map(cell => context.notebookEditor.getCellIndex(cell)));
}
@ -277,6 +282,7 @@ registerAction2(class ExecuteCellAndBelow extends NotebookMultiCellAction {
let startCellIdx: number | undefined = undefined;
if (context.ui) {
startCellIdx = context.notebookEditor.getCellIndex(context.cell);
context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
} else {
startCellIdx = Math.min(...context.selectedCells.map(cell => context.notebookEditor.getCellIndex(cell)));
}
@ -384,6 +390,7 @@ registerAction2(class CancelExecuteCell extends NotebookMultiCellAction {
async runWithContext(accessor: ServicesAccessor, context: INotebookCommandContext | INotebookCellToolbarActionContext): Promise<void> {
if (context.ui) {
context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
return context.notebookEditor.cancelNotebookCells(Iterable.single(context.cell));
} else {
return context.notebookEditor.cancelNotebookCells(context.selectedCells);