Skip to content

Commit 669d397

Browse files
CopilotYoyokrazy
andauthored
Fix cell reveal when followCellExecution enabled and notebook tab not active (microsoft#250646)
* Initial plan for issue * Fix cell reveal when followCellExecution enabled and notebook tab not active - Add ensureNotebookEditorVisible function to bring notebook tab into view before revealing cells - Modify runCell function to ensure notebook editor is visible when autoReveal is enabled - Update all runCell calls to pass editorService for finding and opening notebook editor - Fixes issue where cells were not revealed when notebook tab was not currently active Co-authored-by: Yoyokrazy <12552271+Yoyokrazy@users.noreply.github.com> * whitespace * rm obvious comment + revealIfOpened * the actual correct solution --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Yoyokrazy <12552271+Yoyokrazy@users.noreply.github.com> Co-authored-by: Michael Lively <milively@microsoft.com>
1 parent 43f7e60 commit 669d397

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/vs/workbench/contrib/notebook/browser/controller/executeActions.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function renderAllMarkdownCells(context: INotebookActionContext): void {
7171
}
7272
}
7373

74-
async function runCell(editorGroupsService: IEditorGroupsService, context: INotebookActionContext): Promise<void> {
74+
async function runCell(editorGroupsService: IEditorGroupsService, context: INotebookActionContext, editorService?: IEditorService): Promise<void> {
7575
const group = editorGroupsService.activeGroup;
7676

7777
if (group) {
@@ -80,6 +80,11 @@ async function runCell(editorGroupsService: IEditorGroupsService, context: INote
8080
}
8181
}
8282

83+
// If auto-reveal is enabled, ensure the notebook editor is visible before revealing cells
84+
if (context.autoReveal && (context.cell || context.selectedCells?.length) && editorService) {
85+
editorService.openEditor({ resource: context.notebookEditor.textModel.uri, options: { revealIfOpened: true } });
86+
}
87+
8388
if (context.ui && context.cell) {
8489
if (context.autoReveal) {
8590
handleAutoReveal(context.cell, context.notebookEditor);
@@ -284,6 +289,7 @@ registerAction2(class ExecuteCell extends NotebookMultiCellAction {
284289

285290
async runWithContext(accessor: ServicesAccessor, context: INotebookCommandContext | INotebookCellToolbarActionContext): Promise<void> {
286291
const editorGroupsService = accessor.get(IEditorGroupsService);
292+
const editorService = accessor.get(IEditorService);
287293

288294
if (context.ui) {
289295
await context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
@@ -304,7 +310,7 @@ registerAction2(class ExecuteCell extends NotebookMultiCellAction {
304310
return;
305311
}
306312

307-
await runCell(editorGroupsService, context);
313+
await runCell(editorGroupsService, context, editorService);
308314
}
309315
});
310316

@@ -422,6 +428,7 @@ registerAction2(class ExecuteCellFocusContainer extends NotebookMultiCellAction
422428

423429
async runWithContext(accessor: ServicesAccessor, context: INotebookCommandContext | INotebookCellToolbarActionContext): Promise<void> {
424430
const editorGroupsService = accessor.get(IEditorGroupsService);
431+
const editorService = accessor.get(IEditorService);
425432

426433
if (context.ui) {
427434
await context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
@@ -433,7 +440,7 @@ registerAction2(class ExecuteCellFocusContainer extends NotebookMultiCellAction
433440
}
434441
}
435442

436-
await runCell(editorGroupsService, context);
443+
await runCell(editorGroupsService, context, editorService);
437444
}
438445
});
439446

@@ -526,6 +533,7 @@ registerAction2(class ExecuteCellSelectBelow extends NotebookCellAction {
526533

527534
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
528535
const editorGroupsService = accessor.get(IEditorGroupsService);
536+
const editorService = accessor.get(IEditorService);
529537
const idx = context.notebookEditor.getCellIndex(context.cell);
530538
if (typeof idx !== 'number') {
531539
return;
@@ -568,7 +576,7 @@ registerAction2(class ExecuteCellSelectBelow extends NotebookCellAction {
568576
}
569577
}
570578

571-
return runCell(editorGroupsService, context);
579+
return runCell(editorGroupsService, context, editorService);
572580
}
573581
}
574582
});
@@ -589,6 +597,7 @@ registerAction2(class ExecuteCellInsertBelow extends NotebookCellAction {
589597

590598
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
591599
const editorGroupsService = accessor.get(IEditorGroupsService);
600+
const editorService = accessor.get(IEditorService);
592601
const idx = context.notebookEditor.getCellIndex(context.cell);
593602
const languageService = accessor.get(ILanguageService);
594603
const newFocusMode = context.cell.focusMode === CellFocusMode.Editor ? 'editor' : 'container';
@@ -601,7 +610,7 @@ registerAction2(class ExecuteCellInsertBelow extends NotebookCellAction {
601610
if (context.cell.cellKind === CellKind.Markup) {
602611
context.cell.updateEditState(CellEditState.Preview, EXECUTE_CELL_INSERT_BELOW);
603612
} else {
604-
runCell(editorGroupsService, context);
613+
runCell(editorGroupsService, context, editorService);
605614
}
606615
}
607616
});

0 commit comments

Comments
 (0)