diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 52ce54a9d92..49654cf717d 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -47,6 +47,7 @@ env: VSIX_NAME_PYTHON: 'ms-python-insiders.vsix' VSC_JUPTYER_PYTHON_EXTENSION_VERSION: 'insiders' VSC_JUPYTER_LOG_KERNEL_OUTPUT: true + DOTNET_VERSION: 6.0.x jobs: # Make sure to cancel previous runs on a push diff --git a/package-lock.json b/package-lock.json index 32aea146fed..5b59831711e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3624,10 +3624,11 @@ } }, "@vscode/jupyter-lsp-middleware": { - "version": "0.2.19", - "resolved": "https://registry.npmjs.org/@vscode/jupyter-lsp-middleware/-/jupyter-lsp-middleware-0.2.19.tgz", - "integrity": "sha512-gN4OpeV9t8CDqZI803+hUa94+8N7q49E6SmhuNSH8gNOKZ9I6wx78E4yyMU9iNeZMSdwAEG5n8S70m3ToKysmQ==", + "version": "0.2.21", + "resolved": "https://registry.npmjs.org/@vscode/jupyter-lsp-middleware/-/jupyter-lsp-middleware-0.2.21.tgz", + "integrity": "sha512-yJJRdGtgS25b4M/6evk7/nTsar3E0v0zeJwnS1FYZRL/Ue7hvbKTQBrO4t1mFbrRsh3q0xJzDp1DO2d13jR7uQ==", "requires": { + "sha.js": "^2.4.11", "vscode-languageclient": "7.0.0" } }, @@ -19316,7 +19317,6 @@ "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "dev": true, "requires": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" diff --git a/package.json b/package.json index 38a29bedbbe..7c0f13a4e59 100644 --- a/package.json +++ b/package.json @@ -1980,7 +1980,7 @@ "@jupyterlab/services": "^6.1.17", "@lumino/widgets": "^1.28.0", "@nteract/messaging": "^7.0.0", - "@vscode/jupyter-lsp-middleware": "^0.2.19", + "@vscode/jupyter-lsp-middleware": "^0.2.21", "ansi-to-html": "^0.6.7", "arch": "^2.1.0", "bootstrap": "^4.3.1", diff --git a/src/client/datascience/notebook/intellisense/languageServer.ts b/src/client/datascience/notebook/intellisense/languageServer.ts index cac5fd347cf..47eef02818c 100644 --- a/src/client/datascience/notebook/intellisense/languageServer.ts +++ b/src/client/datascience/notebook/intellisense/languageServer.ts @@ -7,14 +7,12 @@ import { NotebookDocument, workspace, window, - NotebookConcatTextDocument, notebooks, - Event, - Uri + Uri, + NotebookCellsChangeEvent } from 'vscode'; import { ClientCapabilities, - DocumentSelector, DynamicFeature, ExecuteCommandRegistrationOptions, ExecuteCommandRequest, @@ -89,23 +87,6 @@ class NerfedExecuteCommandFeature implements DynamicFeature { - return workspace.onDidOpenNotebookDocument; - } - public get onDidCloseNotebookDocument(): Event { - return workspace.onDidCloseNotebookDocument; - } - public get notebookDocuments(): ReadonlyArray { - return workspace.notebookDocuments; - } - public createConcatTextDocument(doc: NotebookDocument, selector?: DocumentSelector): NotebookConcatTextDocument { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - return notebooks.createConcatTextDocument(doc, selector) as any; - } -})(); - /** * This class wraps an instance of the language server (either Pylance or Jedi LSP) per interpreter. * @@ -121,6 +102,7 @@ export class LanguageServer implements Disposable { private disposables: Disposable[] ) { this._interpreterId = getInterpreterId(interpreter); + notebooks.onDidChangeNotebookCells(this.onDidChangeNotebookCells, this, disposables); } public async dispose() { @@ -157,16 +139,15 @@ export class LanguageServer implements Disposable { const middleware = middlewareType == 'jupyter' ? createNotebookMiddleware( - notebookApi, () => languageClient, () => noop, // Don't trace output. Slows things down too much NOTEBOOK_SELECTOR, - /.*\.(ipynb|interactive)/m, interpreter.path, (uri) => shouldAllowIntellisense(uri, interpreterId, interpreter.path) ) : createPylanceMiddleware( () => languageClient, + NOTEBOOK_SELECTOR, interpreter.path, (uri) => shouldAllowIntellisense(uri, interpreterId, interpreter.path) ); @@ -219,6 +200,11 @@ export class LanguageServer implements Disposable { } } + private onDidChangeNotebookCells(e: NotebookCellsChangeEvent) { + // Tell the middleware to refresh its concat document (pylance or notebook) + this.middleware.refresh(e.document); + } + private static async createServerOptions( interpreter: PythonEnvironment, cancellationStrategy: FileBasedCancellationStrategy @@ -259,7 +245,7 @@ export class LanguageServer implements Disposable { const bundlePath = path.join(distPath, 'server.bundle.js'); const nonBundlePath = path.join(distPath, 'server.js'); const modulePath = (await fs.pathExists(nonBundlePath)) ? nonBundlePath : bundlePath; - const debugOptions = { execArgv: ['--nolazy', '--inspect=6600'] }; + const debugOptions = { execArgv: ['--nolazy', '--inspect=6617'] }; // If the extension is launched in debug mode, then the debug server options are used. const serverOptions: ServerOptions = { diff --git a/src/client/datascience/notebook/notebookControllerManager.ts b/src/client/datascience/notebook/notebookControllerManager.ts index 27436cf6d39..92719275fec 100644 --- a/src/client/datascience/notebook/notebookControllerManager.ts +++ b/src/client/datascience/notebook/notebookControllerManager.ts @@ -69,6 +69,7 @@ export class NotebookControllerManager implements INotebookControllerManager, IE private controllersPromise?: Promise; // Listing of the controllers that we have registered private registeredControllers = new Map(); + private selectedControllers = new Map(); private readonly allKernelConnections = new Set(); private _controllersLoaded?: boolean; public get onNotebookControllerSelectionChanged() { @@ -135,7 +136,7 @@ export class NotebookControllerManager implements INotebookControllerManager, IE return this._onNotebookControllerSelected.event; } public getSelectedNotebookController(notebook: NotebookDocument) { - return Array.from(this.registeredControllers.values()).find((item) => item.isAssociatedWithDocument(notebook)); + return this.selectedControllers.get(notebook.uri.toString()); } public getPreferredNotebookController(notebook: NotebookDocument) { @@ -601,6 +602,7 @@ export class NotebookControllerManager implements INotebookControllerManager, IE controller: VSCodeNotebookController; }) { traceInfoIfCI(`Controller ${event.controller?.id} selected`); + this.selectedControllers.set(event.notebook.uri.toString(), event.controller); // Now notify out that we have updated a notebooks controller this._onNotebookControllerSelected.fire(event); }