From 726f9c95dae27db5bd04b35fad2f0117ee12ecf3 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 18 Feb 2022 21:38:41 -0800 Subject: [PATCH] Focus cell when executed via UI Fix #143268 --- .../contrib/notebook/browser/controller/executeActions.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/vs/workbench/contrib/notebook/browser/controller/executeActions.ts b/src/vs/workbench/contrib/notebook/browser/controller/executeActions.ts index 535a271ba22..063d3812d0e 100644 --- a/src/vs/workbench/contrib/notebook/browser/controller/executeActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/controller/executeActions.ts @@ -193,6 +193,10 @@ registerAction2(class ExecuteCell extends NotebookMultiCellAction { } async runWithContext(accessor: ServicesAccessor, context: INotebookCommandContext | INotebookCellToolbarActionContext): Promise { + 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 { 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);