diff --git a/extensions/vscode-notebook-tests/src/notebook.test.ts b/extensions/vscode-notebook-tests/src/notebook.test.ts index 374c1674253b2f2b65bbe5308413b8eecd109448..d835bb949299df3c5619febde809ebe1523c9612 100644 --- a/extensions/vscode-notebook-tests/src/notebook.test.ts +++ b/extensions/vscode-notebook-tests/src/notebook.test.ts @@ -46,7 +46,7 @@ suite('notebook workflow', () => { }); test('notebook cell actions', async function () { - const resource = vscode.Uri.parse(join(vscode.workspace.rootPath || '', './second.vsctestnb')); + const resource = vscode.Uri.parse(join(vscode.workspace.rootPath || '', './first.vsctestnb')); await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest'); await waitFor(500); diff --git a/extensions/vscode-notebook-tests/test/second.vsctestnb b/extensions/vscode-notebook-tests/test/second.vsctestnb deleted file mode 100644 index a4a092d83492f73541c48127da38563b8fce621d..0000000000000000000000000000000000000000 --- a/extensions/vscode-notebook-tests/test/second.vsctestnb +++ /dev/null @@ -1,4 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts index a4c27c6fc7b5214a69cf0c66070aad3be454fb77..2cd9fb3fad1966f5ec490430b56cbcf20ad81b65 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts @@ -513,10 +513,10 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor { this.list!.layout(); // restore list state at last, it must be after list layout - this.restoreTextEditorViewState(viewState); + this.restoreListViewState(viewState); } - private restoreTextEditorViewState(viewState: INotebookEditorViewState | undefined): void { + private restoreListViewState(viewState: INotebookEditorViewState | undefined): void { if (viewState?.scrollPosition !== undefined) { this.list!.scrollTop = viewState!.scrollPosition.top; this.list!.scrollLeft = viewState!.scrollPosition.left; @@ -526,8 +526,12 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor { } const focusIdx = typeof viewState?.focus === 'number' ? viewState.focus : 0; - this.list!.setFocus([focusIdx]); - this.list!.setSelection([focusIdx]); + if (focusIdx < this.list!.length) { + this.list!.setFocus([focusIdx]); + this.list!.setSelection([focusIdx]); + } else if (this.list!.length > 0) { + this.list!.setFocus([0]); + } if (viewState?.editorFocused) { this.list?.focusView();