Skip to content

Commit

Permalink
Remove old notebook editor api proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Oct 24, 2022
1 parent ce340cb commit d776718
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,23 @@ import * as utils from '../utils';
test('Opening a notebook should fire activeNotebook event changed only once', async function () {
const openedEditor = onDidOpenNotebookEditor();
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
const editor = await vscode.window.showNotebookDocument(resource);
const document = await vscode.workspace.openNotebookDocument(resource);
const editor = await vscode.window.showNotebookDocument(document);
assert.ok(await openedEditor);
assert.strictEqual(editor.notebook.uri.toString(), resource.toString());
});

test('Active/Visible Editor', async function () {
const firstEditorOpen = onDidOpenNotebookEditor();
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
const firstEditor = await vscode.window.showNotebookDocument(resource);
const document = await vscode.workspace.openNotebookDocument(resource);

const firstEditor = await vscode.window.showNotebookDocument(document);
await firstEditorOpen;
assert.strictEqual(vscode.window.activeNotebookEditor, firstEditor);
assert.strictEqual(vscode.window.visibleNotebookEditors.includes(firstEditor), true);

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

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

test('Notebook Editor Event - onDidChangeVisibleNotebookEditors on two editor groups', async function () {
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
const document = await vscode.workspace.openNotebookDocument(resource);

let count = 0;
testDisposables.push(vscode.window.onDidChangeVisibleNotebookEditors(() => {
count = vscode.window.visibleNotebookEditors.length;
}));

await vscode.window.showNotebookDocument(resource, { viewColumn: vscode.ViewColumn.Active });
await vscode.window.showNotebookDocument(document, { viewColumn: vscode.ViewColumn.Active });
assert.strictEqual(count, 1);

await vscode.window.showNotebookDocument(resource, { viewColumn: vscode.ViewColumn.Beside });
await vscode.window.showNotebookDocument(document, { viewColumn: vscode.ViewColumn.Beside });
assert.strictEqual(count, 2);

await utils.closeAllEditors();
Expand Down
8 changes: 2 additions & 6 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
onDidChangeNotebookEditorVisibleRanges(listener, thisArgs?, disposables?) {
return extHostNotebookEditors.onDidChangeNotebookEditorVisibleRanges(listener, thisArgs, disposables);
},
showNotebookDocument(uriOrDocument, options?) {
if (URI.isUri(uriOrDocument)) {
extHostApiDeprecation.report('window.showNotebookDocument(uri)', extension,
`Please use 'workspace.openNotebookDocument' and 'window.showNotebookDocument'`);
}
return extHostNotebook.showNotebookDocument(uriOrDocument, options);
showNotebookDocument(document, options?) {
return extHostNotebook.showNotebookDocument(document, options);
},
registerExternalUriOpener(id: string, opener: vscode.ExternalUriOpener, metadata: vscode.ExternalUriOpenerMetadata) {
checkProposedApiEnabled(extension, 'externalUriOpener');
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/api/common/extHostNotebookDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class ExtHostCell {
get index() { return that.notebook.getCellIndex(that); },
notebook: that.notebook.apiNotebook,
kind: extHostTypeConverters.NotebookCellKind.to(this._cellData.cellKind),
document: data.document,
get mime() { return that._mime; },
set mime(value: string | undefined) { that._mime = value; },
get outputs() { return that._outputs.slice(0); },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const allApiProposals = Object.freeze({
notebookControllerAffinityHidden: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookControllerAffinityHidden.d.ts',
notebookControllerKind: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookControllerKind.d.ts',
notebookDeprecated: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookDeprecated.d.ts',
notebookEditor: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookEditor.d.ts',
notebookKernelSource: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookKernelSource.d.ts',
notebookLiveShare: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookLiveShare.d.ts',
notebookMessaging: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookMessaging.d.ts',
Expand Down
37 changes: 0 additions & 37 deletions src/vscode-dts/vscode.proposed.notebookEditor.d.ts

This file was deleted.

0 comments on commit d776718

Please sign in to comment.