Skip to content

Commit 4eef476

Browse files
authored
Remove old notebook editor api proposal (microsoft#164504)
All consumers should now be on the finalized api Fixes microsoft#151661
1 parent 52f46cc commit 4eef476

File tree

5 files changed

+16
-42
lines changed

5 files changed

+16
-42
lines changed

extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,23 @@ import * as utils from '../utils';
6969
test('Opening a notebook should fire activeNotebook event changed only once', async function () {
7070
const openedEditor = onDidOpenNotebookEditor();
7171
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
72-
const editor = await vscode.window.showNotebookDocument(resource);
72+
const document = await vscode.workspace.openNotebookDocument(resource);
73+
const editor = await vscode.window.showNotebookDocument(document);
7374
assert.ok(await openedEditor);
7475
assert.strictEqual(editor.notebook.uri.toString(), resource.toString());
7576
});
7677

7778
test('Active/Visible Editor', async function () {
7879
const firstEditorOpen = onDidOpenNotebookEditor();
7980
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
80-
const firstEditor = await vscode.window.showNotebookDocument(resource);
81+
const document = await vscode.workspace.openNotebookDocument(resource);
82+
83+
const firstEditor = await vscode.window.showNotebookDocument(document);
8184
await firstEditorOpen;
8285
assert.strictEqual(vscode.window.activeNotebookEditor, firstEditor);
8386
assert.strictEqual(vscode.window.visibleNotebookEditors.includes(firstEditor), true);
8487

85-
const secondEditor = await vscode.window.showNotebookDocument(resource, { viewColumn: vscode.ViewColumn.Beside });
88+
const secondEditor = await vscode.window.showNotebookDocument(document, { viewColumn: vscode.ViewColumn.Beside });
8689
// There is no guarantee that when `showNotebookDocument` resolves, the active notebook editor is already updated correctly.
8790
// assert.strictEqual(secondEditor === vscode.window.activeNotebookEditor, true);
8891
assert.notStrictEqual(firstEditor, secondEditor);
@@ -95,7 +98,8 @@ import * as utils from '../utils';
9598
test('Notebook Editor Event - onDidChangeVisibleNotebookEditors on open/close', async function () {
9699
const openedEditor = utils.asPromise(vscode.window.onDidChangeVisibleNotebookEditors);
97100
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
98-
await vscode.window.showNotebookDocument(resource);
101+
const document = await vscode.workspace.openNotebookDocument(resource);
102+
await vscode.window.showNotebookDocument(document);
99103
assert.ok(await openedEditor);
100104

101105
const firstEditorClose = utils.asPromise(vscode.window.onDidChangeVisibleNotebookEditors);
@@ -105,15 +109,17 @@ import * as utils from '../utils';
105109

106110
test('Notebook Editor Event - onDidChangeVisibleNotebookEditors on two editor groups', async function () {
107111
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
112+
const document = await vscode.workspace.openNotebookDocument(resource);
113+
108114
let count = 0;
109115
testDisposables.push(vscode.window.onDidChangeVisibleNotebookEditors(() => {
110116
count = vscode.window.visibleNotebookEditors.length;
111117
}));
112118

113-
await vscode.window.showNotebookDocument(resource, { viewColumn: vscode.ViewColumn.Active });
119+
await vscode.window.showNotebookDocument(document, { viewColumn: vscode.ViewColumn.Active });
114120
assert.strictEqual(count, 1);
115121

116-
await vscode.window.showNotebookDocument(resource, { viewColumn: vscode.ViewColumn.Beside });
122+
await vscode.window.showNotebookDocument(document, { viewColumn: vscode.ViewColumn.Beside });
117123
assert.strictEqual(count, 2);
118124

119125
await utils.closeAllEditors();

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -793,12 +793,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
793793
onDidChangeNotebookEditorVisibleRanges(listener, thisArgs?, disposables?) {
794794
return extHostNotebookEditors.onDidChangeNotebookEditorVisibleRanges(listener, thisArgs, disposables);
795795
},
796-
showNotebookDocument(uriOrDocument, options?) {
797-
if (URI.isUri(uriOrDocument)) {
798-
extHostApiDeprecation.report('window.showNotebookDocument(uri)', extension,
799-
`Please use 'workspace.openNotebookDocument' and 'window.showNotebookDocument'`);
800-
}
801-
return extHostNotebook.showNotebookDocument(uriOrDocument, options);
796+
showNotebookDocument(document, options?) {
797+
return extHostNotebook.showNotebookDocument(document, options);
802798
},
803799
registerExternalUriOpener(id: string, opener: vscode.ExternalUriOpener, metadata: vscode.ExternalUriOpenerMetadata) {
804800
checkProposedApiEnabled(extension, 'externalUriOpener');

src/vs/workbench/api/common/extHostNotebookEditor.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ export class ExtHostNotebookEditor {
3939
if (!this._editor) {
4040
const that = this;
4141
this._editor = {
42-
get document() {
43-
return that.notebookData.apiNotebook;
44-
},
4542
get notebook() {
4643
return that.notebookData.apiNotebook;
4744
},

src/vs/workbench/api/common/extHostNotebookKernels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
7474
} else if (v && 'notebookEditor' in v) {
7575
const notebookEditorId = this._extHostNotebook.getIdByEditor(v.notebookEditor);
7676
if (notebookEditorId === undefined) {
77-
throw new Error(`Cannot invoke 'notebook.selectKernel' for unrecognized notebook editor ${v.notebookEditor.document.uri.toString()}`);
77+
throw new Error(`Cannot invoke 'notebook.selectKernel' for unrecognized notebook editor ${v.notebookEditor.notebook.uri.toString()}`);
7878
}
7979
return { notebookEditorId };
8080
}

src/vscode-dts/vscode.proposed.notebookEditor.d.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,5 @@ declare module 'vscode' {
88
// https://github.com/microsoft/vscode/issues/149271
99

1010
// ❗️ Important: The main NotebookEditor api has been finalized.
11-
// This file only contains deprecated properties/functions from the proposal.
12-
13-
export interface NotebookEditor {
14-
/**
15-
* The document associated with this notebook editor.
16-
*
17-
* @deprecated Use {@linkcode NotebookEditor.notebook} instead.
18-
*/
19-
readonly document: NotebookDocument;
20-
}
21-
22-
export namespace window {
23-
/**
24-
* A short-hand for `openNotebookDocument(uri).then(document => showNotebookDocument(document, options))`.
25-
*
26-
* @deprecated Will not be finalized.
27-
*
28-
* @see {@link workspace.openNotebookDocument}
29-
*
30-
* @param uri The resource to open.
31-
* @param options {@link NotebookDocumentShowOptions Editor options} to configure the behavior of showing the {@link NotebookEditor notebook editor}.
32-
*
33-
* @return A promise that resolves to an {@link NotebookEditor notebook editor}.
34-
*/
35-
export function showNotebookDocument(uri: Uri, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
36-
}
11+
// This file only tracks the `notebook/cell/executePrimary` contribution, which will be removed
3712
}

0 commit comments

Comments
 (0)