From e8ce2dae3e2165f6a22194644d506e5d2844d3da Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Thu, 3 Jun 2021 11:06:25 -0700 Subject: [PATCH 1/3] notebook renamed to notebooks, notebooks symbols moved to workspace namespace --- src/client/common/application/notebook.ts | 19 ++++++++++--------- .../insiders/languageServer.insiders.test.ts | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/client/common/application/notebook.ts b/src/client/common/application/notebook.ts index b84544a31642..ccc20659c7fb 100644 --- a/src/client/common/application/notebook.ts +++ b/src/client/common/application/notebook.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import { DocumentSelector, Event, EventEmitter } from 'vscode'; +import { DocumentSelector, Event, EventEmitter, workspace } from 'vscode'; import type { notebook, NotebookConcatTextDocument, NotebookDocument } from 'vscode-proposed'; import { UseProposedApi } from '../constants'; import { IApplicationEnvironment, IVSCodeNotebook } from './types'; @@ -10,21 +10,22 @@ import { IApplicationEnvironment, IVSCodeNotebook } from './types'; @injectable() export class VSCodeNotebook implements IVSCodeNotebook { public get onDidOpenNotebookDocument(): Event { - return this.canUseNotebookApi - ? this.notebook.onDidOpenNotebookDocument - : new EventEmitter().event; + const onDidOpenNotebookDocument = + this.notebook.onDidOpenNotebookDocument ?? (workspace as any).onDidOpenNotebookDocument; + return this.canUseNotebookApi ? onDidOpenNotebookDocument : new EventEmitter().event; } public get onDidCloseNotebookDocument(): Event { - return this.canUseNotebookApi - ? this.notebook.onDidCloseNotebookDocument - : new EventEmitter().event; + const onDidCloseNotebookDocument = + this.notebook.onDidCloseNotebookDocument ?? (workspace as any).onDidCloseNotebookDocument; + return this.canUseNotebookApi ? onDidCloseNotebookDocument : new EventEmitter().event; } public get notebookDocuments(): ReadonlyArray { - return this.canUseNotebookApi ? this.notebook.notebookDocuments : []; + const notebookDocuments = this.notebook.notebookDocuments ?? (workspace as any).notebookDocuments; + return this.canUseNotebookApi ? notebookDocuments : []; } private get notebook() { if (!this._notebook) { - this._notebook = require('vscode').notebook; + this._notebook = require('vscode').notebook ?? require('vscode').notebooks; } return this._notebook!; } diff --git a/src/test/insiders/languageServer.insiders.test.ts b/src/test/insiders/languageServer.insiders.test.ts index 54a095adbe24..00f186c5129c 100644 --- a/src/test/insiders/languageServer.insiders.test.ts +++ b/src/test/insiders/languageServer.insiders.test.ts @@ -88,9 +88,10 @@ suite('Insiders Test: Language Server', () => { const notebookDocument = await openNotebookAndWaitForLS(notebookDefinitions); let tested = false; for (let i = 0; i < 5; i += 1) { + const uri = notebookDocument.cellAt(2).document.uri; const locations = await vscode.commands.executeCommand( 'vscode.executeDefinitionProvider', - notebookDocument.cellAt(2).document.uri, // Second cell should have a function with the decorator on it + uri, // Second cell should have a function with the decorator on it startPosition, ); if (locations && locations.length > 0) { From 4e60551b21807773f877f86f5068b5f618367bd3 Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Thu, 3 Jun 2021 11:15:04 -0700 Subject: [PATCH 2/3] Fix lint --- src/test/insiders/languageServer.insiders.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/insiders/languageServer.insiders.test.ts b/src/test/insiders/languageServer.insiders.test.ts index 00f186c5129c..54a095adbe24 100644 --- a/src/test/insiders/languageServer.insiders.test.ts +++ b/src/test/insiders/languageServer.insiders.test.ts @@ -88,10 +88,9 @@ suite('Insiders Test: Language Server', () => { const notebookDocument = await openNotebookAndWaitForLS(notebookDefinitions); let tested = false; for (let i = 0; i < 5; i += 1) { - const uri = notebookDocument.cellAt(2).document.uri; const locations = await vscode.commands.executeCommand( 'vscode.executeDefinitionProvider', - uri, // Second cell should have a function with the decorator on it + notebookDocument.cellAt(2).document.uri, // Second cell should have a function with the decorator on it startPosition, ); if (locations && locations.length > 0) { From 866f94c2bbcce72c78d55c0ab2839dfbe1faea3f Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Thu, 3 Jun 2021 11:33:47 -0700 Subject: [PATCH 3/3] Drop usage of NotebookCellMetadata ctor --- .../insiders/languageServer.insiders.test.ts | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/test/insiders/languageServer.insiders.test.ts b/src/test/insiders/languageServer.insiders.test.ts index 54a095adbe24..be504fe82f1f 100644 --- a/src/test/insiders/languageServer.insiders.test.ts +++ b/src/test/insiders/languageServer.insiders.test.ts @@ -101,15 +101,7 @@ suite('Insiders Test: Language Server', () => { expect(activeEditor).not.to.be.equal(undefined, 'Active editor not found in notebook'); await activeEditor!.edit((edit) => { edit.replaceCells(0, 0, [ - new vscode.NotebookCellData( - vscode.NotebookCellKind.Code, - PYTHON_LANGUAGE, - 'x = 4', - [], - new vscode.NotebookCellMetadata().with({ - hasExecutionOrder: false, - }), - ), + new vscode.NotebookCellData(vscode.NotebookCellKind.Code, PYTHON_LANGUAGE, 'x = 4', []), ]); }); @@ -124,15 +116,7 @@ suite('Insiders Test: Language Server', () => { await activeEditor!.edit((edit) => { edit.replaceCells(0, 1, []); edit.replaceCells(1, 0, [ - new vscode.NotebookCellData( - vscode.NotebookCellKind.Code, - PYTHON_LANGUAGE, - 'x = 4', - [], - new vscode.NotebookCellMetadata().with({ - hasExecutionOrder: false, - }), - ), + new vscode.NotebookCellData(vscode.NotebookCellKind.Code, PYTHON_LANGUAGE, 'x = 4', []), ]); });