diff --git a/src/features/PowerShellNotebooks.ts b/src/features/PowerShellNotebooks.ts index 730b9e66e5..99011414ec 100644 --- a/src/features/PowerShellNotebooks.ts +++ b/src/features/PowerShellNotebooks.ts @@ -96,7 +96,7 @@ export class PowerShellNotebooksFeature extends LanguageClientConsumer { } private static async DisableNotebookMode() { - const uri = vscode.notebook.activeNotebookEditor.document.uri; + const uri = vscode.window.activeNotebookEditor.document.uri; await vscode.commands.executeCommand("workbench.action.closeActiveEditor"); await vscode.commands.executeCommand("vscode.openWith", uri, "default"); } diff --git a/test/features/PowerShellNotebooks.test.ts b/test/features/PowerShellNotebooks.test.ts index 38fcc573fe..b0a54a0bcd 100644 --- a/test/features/PowerShellNotebooks.test.ts +++ b/test/features/PowerShellNotebooks.test.ts @@ -350,11 +350,11 @@ suite("PowerShellNotebooks tests", () => { // Allow some time to pass to render the Notebook await utils.sleep(5000); assert.strictEqual( - vscode.notebook.activeNotebookEditor.document.uri.toString(), + vscode.window.activeNotebookEditor.document.uri.toString(), notebookSimpleMixedComments.toString()); // Save it as testFile.ps1 and reopen it using the feature. - await notebookContentProvider.saveNotebookAs(uri, vscode.notebook.activeNotebookEditor.document, null); + await notebookContentProvider.saveNotebookAs(uri, vscode.window.activeNotebookEditor.document, null); const newNotebook = await notebookContentProvider.openNotebook(uri, {}); // Compare that saving as a file results in the same cell data as the existing one. @@ -376,12 +376,12 @@ suite("PowerShellNotebooks tests", () => { // Allow some time to pass to render the Notebook await utils.sleep(5000); assert.strictEqual( - vscode.notebook.activeNotebookEditor.document.uri.toString(), + vscode.window.activeNotebookEditor.document.uri.toString(), notebookBlockCommentsWithTextOnSameLine.toString()); // Save it as testFile1.ps1 const contentOfBackingFileBefore = (await vscode.workspace.fs.readFile(notebookBlockCommentsWithTextOnSameLine)).toString(); - await notebookContentProvider.saveNotebookAs(uri, vscode.notebook.activeNotebookEditor.document, null); + await notebookContentProvider.saveNotebookAs(uri, vscode.window.activeNotebookEditor.document, null); const contentOfBackingFileAfter = (await vscode.workspace.fs.readFile(uri)).toString(); // Verify that saving does not mutate result. @@ -405,10 +405,10 @@ gci`, test(".Notebook.ps1 files are opened automatically", async () => { await vscode.commands.executeCommand("vscode.open", notebookSimpleDotNotebook); - assert.strictEqual(vscode.notebook.activeNotebookEditor.document.cells.length, 2); - assert.strictEqual(vscode.notebook.activeNotebookEditor.document.cells[0].cellKind, vscode.CellKind.Markdown); - assert.strictEqual(vscode.notebook.activeNotebookEditor.document.cells[0].document.getText(), "asdf"); - assert.strictEqual(vscode.notebook.activeNotebookEditor.document.cells[1].cellKind, vscode.CellKind.Code); - assert.strictEqual(vscode.notebook.activeNotebookEditor.document.cells[1].document.getText(), "gci\n"); + assert.strictEqual(vscode.window.activeNotebookEditor.document.cells.length, 2); + assert.strictEqual(vscode.window.activeNotebookEditor.document.cells[0].cellKind, vscode.CellKind.Markdown); + assert.strictEqual(vscode.window.activeNotebookEditor.document.cells[0].document.getText(), "asdf"); + assert.strictEqual(vscode.window.activeNotebookEditor.document.cells[1].cellKind, vscode.CellKind.Code); + assert.strictEqual(vscode.window.activeNotebookEditor.document.cells[1].document.getText(), "gci\n"); }).timeout(20000); }); diff --git a/vscode.proposed.d.ts b/vscode.proposed.d.ts index bed0820e02..f56f3abdf4 100644 --- a/vscode.proposed.d.ts +++ b/vscode.proposed.d.ts @@ -341,16 +341,6 @@ declare module 'vscode' { */ readonly viewColumn?: ViewColumn; - /** - * Whether the panel is active (focused by the user). - */ - readonly active: boolean; - - /** - * Whether the panel is visible. - */ - readonly visible: boolean; - /** * Fired when the panel is disposed. */ @@ -687,6 +677,7 @@ declare module 'vscode' { ): Disposable; export function createNotebookEditorDecorationType(options: NotebookDecorationRenderOptions): NotebookEditorDecorationType; + export function openNotebookDocument(uri: Uri, viewType?: string): Promise; export const onDidOpenNotebookDocument: Event; export const onDidCloseNotebookDocument: Event; export const onDidSaveNotebookDocument: Event; @@ -695,14 +686,6 @@ declare module 'vscode' { * All currently known notebook documents. */ export const notebookDocuments: ReadonlyArray; - - export const visibleNotebookEditors: NotebookEditor[]; - export const onDidChangeVisibleNotebookEditors: Event; - - export const activeNotebookEditor: NotebookEditor | undefined; - export const onDidChangeActiveNotebookEditor: Event; - export const onDidChangeNotebookEditorSelection: Event; - export const onDidChangeNotebookEditorVisibleRanges: Event; export const onDidChangeNotebookDocumentMetadata: Event; export const onDidChangeNotebookCells: Event; export const onDidChangeCellOutputs: Event; @@ -731,5 +714,14 @@ declare module 'vscode' { export function createCellStatusBarItem(cell: NotebookCell, alignment?: NotebookCellStatusBarAlignment, priority?: number): NotebookCellStatusBarItem; } + export namespace window { + export const visibleNotebookEditors: NotebookEditor[]; + export const onDidChangeVisibleNotebookEditors: Event; + export const activeNotebookEditor: NotebookEditor | undefined; + export const onDidChangeActiveNotebookEditor: Event; + export const onDidChangeNotebookEditorSelection: Event; + export const onDidChangeNotebookEditorVisibleRanges: Event; + } + //#endregion }