Skip to content

Commit b3162f5

Browse files
committed
wait for notebook focus after cell movement.
1 parent 23f5231 commit b3162f5

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ registerAction2(class extends NotebookAction {
226226
// Try to select below, fall back on inserting
227227
const nextCell = context.notebookEditor.viewModel?.viewCells[idx + 1];
228228
if (nextCell) {
229-
context.notebookEditor.focusNotebookCell(nextCell, context.cell.editState === CellEditState.Editing ? 'editor' : 'container');
229+
await context.notebookEditor.focusNotebookCell(nextCell, context.cell.editState === CellEditState.Editing ? 'editor' : 'container');
230230
} else {
231231
const newCell = context.notebookEditor.insertNotebookCell(context.cell, CellKind.Code, 'below');
232232
if (newCell) {
233-
context.notebookEditor.focusNotebookCell(newCell, 'editor');
233+
await context.notebookEditor.focusNotebookCell(newCell, 'editor');
234234
}
235235
}
236236
}
@@ -256,7 +256,7 @@ registerAction2(class extends NotebookAction {
256256
await runCell(context);
257257
const newCell = context.notebookEditor.insertNotebookCell(context.cell, CellKind.Code, 'below');
258258
if (newCell) {
259-
context.notebookEditor.focusNotebookCell(newCell, 'editor');
259+
await context.notebookEditor.focusNotebookCell(newCell, 'editor');
260260
}
261261
}
262262
});
@@ -313,7 +313,7 @@ registerAction2(class extends NotebookAction {
313313
context.cell.editState = CellEditState.Preview;
314314
}
315315

316-
context.notebookEditor.focusNotebookCell(context.cell, 'container');
316+
await context.notebookEditor.focusNotebookCell(context.cell, 'container');
317317
}
318318
});
319319

@@ -436,7 +436,7 @@ export async function changeCellToKind(kind: CellKind, context: INotebookCellAct
436436
newCell.model.language = language;
437437
}
438438

439-
notebookEditor.focusNotebookCell(newCell, cell.editState === CellEditState.Editing ? 'editor' : 'container');
439+
await notebookEditor.focusNotebookCell(newCell, cell.editState === CellEditState.Editing ? 'editor' : 'container');
440440
notebookEditor.deleteNotebookCell(cell);
441441

442442
return newCell;
@@ -461,7 +461,7 @@ abstract class InsertCellCommand extends NotebookAction {
461461
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
462462
const newCell = context.notebookEditor.insertNotebookCell(context.cell, this.kind, this.direction, undefined, context.ui);
463463
if (newCell) {
464-
context.notebookEditor.focusNotebookCell(newCell, 'editor');
464+
await context.notebookEditor.focusNotebookCell(newCell, 'editor');
465465
}
466466
}
467467
}
@@ -656,12 +656,12 @@ registerAction2(class extends NotebookAction {
656656
// deletion succeeds, move focus to the next cell
657657
const nextCellIdx = index < context.notebookEditor.viewModel!.length ? index : context.notebookEditor.viewModel!.length - 1;
658658
if (nextCellIdx >= 0) {
659-
context.notebookEditor.focusNotebookCell(context.notebookEditor.viewModel!.viewCells[nextCellIdx], 'container');
659+
await context.notebookEditor.focusNotebookCell(context.notebookEditor.viewModel!.viewCells[nextCellIdx], 'container');
660660
} else {
661661
// No cells left, insert a new empty one
662662
const newCell = context.notebookEditor.insertNotebookCell(undefined, context.cell.cellKind);
663663
if (newCell) {
664-
context.notebookEditor.focusNotebookCell(newCell, 'editor');
664+
await context.notebookEditor.focusNotebookCell(newCell, 'editor');
665665
}
666666
}
667667
}
@@ -675,7 +675,7 @@ async function moveCell(context: INotebookCellActionContext, direction: 'up' | '
675675

676676
if (result) {
677677
// move cell command only works when the cell container has focus
678-
context.notebookEditor.focusNotebookCell(context.cell, 'container');
678+
await context.notebookEditor.focusNotebookCell(context.cell, 'container');
679679
}
680680
}
681681

@@ -684,7 +684,7 @@ async function copyCell(context: INotebookCellActionContext, direction: 'up' | '
684684
const newCellDirection = direction === 'up' ? 'above' : 'below';
685685
const newCell = context.notebookEditor.insertNotebookCell(context.cell, context.cell.cellKind, newCellDirection, text);
686686
if (newCell) {
687-
context.notebookEditor.focusNotebookCell(newCell, 'container');
687+
await context.notebookEditor.focusNotebookCell(newCell, 'container');
688688
}
689689
}
690690

@@ -935,7 +935,7 @@ registerAction2(class extends NotebookAction {
935935
return;
936936
}
937937

938-
editor.focusNotebookCell(newCell, 'editor');
938+
await editor.focusNotebookCell(newCell, 'editor');
939939
}
940940
});
941941

@@ -973,7 +973,7 @@ registerAction2(class extends NotebookAction {
973973
return;
974974
}
975975

976-
editor.focusNotebookCell(newCell, 'editor');
976+
await editor.focusNotebookCell(newCell, 'editor');
977977
}
978978
});
979979

@@ -997,7 +997,7 @@ registerAction2(class extends NotebookAction {
997997
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
998998
const editor = context.notebookEditor;
999999
const activeCell = context.cell;
1000-
editor.focusNotebookCell(activeCell, 'output');
1000+
await editor.focusNotebookCell(activeCell, 'output');
10011001
}
10021002
});
10031003

@@ -1021,7 +1021,7 @@ registerAction2(class extends NotebookAction {
10211021
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
10221022
const editor = context.notebookEditor;
10231023
const activeCell = context.cell;
1024-
editor.focusNotebookCell(activeCell, 'editor');
1024+
await editor.focusNotebookCell(activeCell, 'editor');
10251025
}
10261026
});
10271027

@@ -1094,7 +1094,7 @@ registerAction2(class extends NotebookAction {
10941094
}
10951095

10961096
const firstCell = editor.viewModel.viewCells[0];
1097-
editor.focusNotebookCell(firstCell, 'container');
1097+
await editor.focusNotebookCell(firstCell, 'container');
10981098
}
10991099
});
11001100

@@ -1122,7 +1122,7 @@ registerAction2(class extends NotebookAction {
11221122
}
11231123

11241124
const firstCell = editor.viewModel.viewCells[editor.viewModel.length - 1];
1125-
editor.focusNotebookCell(firstCell, 'container');
1125+
await editor.focusNotebookCell(firstCell, 'container');
11261126
}
11271127
});
11281128

@@ -1225,7 +1225,7 @@ export class ChangeCellLanguageAction extends NotebookAction {
12251225
if (selection.languageId === 'markdown' && context.cell?.language !== 'markdown') {
12261226
const newCell = await changeCellToKind(CellKind.Markdown, { cell: context.cell, notebookEditor: context.notebookEditor });
12271227
if (newCell) {
1228-
context.notebookEditor.focusNotebookCell(newCell, 'editor');
1228+
await context.notebookEditor.focusNotebookCell(newCell, 'editor');
12291229
}
12301230
} else if (selection.languageId !== 'markdown' && context.cell?.language === 'markdown') {
12311231
await changeCellToKind(CellKind.Code, { cell: context.cell, notebookEditor: context.notebookEditor }, selection.languageId);
@@ -1288,7 +1288,7 @@ async function splitCell(context: INotebookCellActionContext): Promise<void> {
12881288
if (context.cell.cellKind === CellKind.Code) {
12891289
const newCells = await context.notebookEditor.splitNotebookCell(context.cell);
12901290
if (newCells) {
1291-
context.notebookEditor.focusNotebookCell(newCells[newCells.length - 1], 'editor');
1291+
await context.notebookEditor.focusNotebookCell(newCells[newCells.length - 1], 'editor');
12921292
}
12931293
}
12941294
}
@@ -1320,7 +1320,7 @@ registerAction2(class extends NotebookAction {
13201320
async function joinCells(context: INotebookCellActionContext, direction: 'above' | 'below'): Promise<void> {
13211321
const cell = await context.notebookEditor.joinNotebookCells(context.cell, direction, CellKind.Code);
13221322
if (cell) {
1323-
context.notebookEditor.focusNotebookCell(cell, 'editor');
1323+
await context.notebookEditor.focusNotebookCell(cell, 'editor');
13241324
}
13251325
}
13261326

0 commit comments

Comments
 (0)