Skip to content

Commit cea1d2f

Browse files
committed
fix notebook integration test
1 parent 6d79f86 commit cea1d2f

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

extensions/vscode-notebook-tests/src/notebook.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ suite('notebook workflow', () => {
4646
});
4747

4848
test('notebook cell actions', async function () {
49-
const resource = vscode.Uri.parse(join(vscode.workspace.rootPath || '', './second.vsctestnb'));
49+
const resource = vscode.Uri.parse(join(vscode.workspace.rootPath || '', './first.vsctestnb'));
5050
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
5151

5252
await waitFor(500);

extensions/vscode-notebook-tests/test/second.vsctestnb

Lines changed: 0 additions & 4 deletions
This file was deleted.

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,10 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
513513
this.list!.layout();
514514

515515
// restore list state at last, it must be after list layout
516-
this.restoreTextEditorViewState(viewState);
516+
this.restoreListViewState(viewState);
517517
}
518518

519-
private restoreTextEditorViewState(viewState: INotebookEditorViewState | undefined): void {
519+
private restoreListViewState(viewState: INotebookEditorViewState | undefined): void {
520520
if (viewState?.scrollPosition !== undefined) {
521521
this.list!.scrollTop = viewState!.scrollPosition.top;
522522
this.list!.scrollLeft = viewState!.scrollPosition.left;
@@ -526,8 +526,12 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
526526
}
527527

528528
const focusIdx = typeof viewState?.focus === 'number' ? viewState.focus : 0;
529-
this.list!.setFocus([focusIdx]);
530-
this.list!.setSelection([focusIdx]);
529+
if (focusIdx < this.list!.length) {
530+
this.list!.setFocus([focusIdx]);
531+
this.list!.setSelection([focusIdx]);
532+
} else if (this.list!.length > 0) {
533+
this.list!.setFocus([0]);
534+
}
531535

532536
if (viewState?.editorFocused) {
533537
this.list?.focusView();

0 commit comments

Comments
 (0)