Add opt-in refreshExtensionOnPackagesChange to restart the language server on package changes#72
Conversation
… event internal Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Solid, well-scoped opt-in feature. The main thing to resolve before merge is that the package-change subscription is only wired when the Python extension resolves the interpreter — pinning an interpreter via setting makes |
|
Solid, well-scoped opt-in feature. The main thing to resolve before merge is the pinned-interpreter dead zone: when |
…rden subscription - Wire onDidChangePackages refresh regardless of how the interpreter was chosen (resolved by the Python extension or pinned via setting), so refreshExtensionOnPackagesChange is never silently inert. - Move the subscription into a dedicated, non-fatal PythonEnvironmentsProvider.subscribeToPackageChanges (guards typeof + try/catch, returns undefined on failure) so it can never block server startup. - Add a trailing-edge debounce around the package trigger to collapse bursty multi-package installs into one restart. - Add real subscription test (fake IPythonApi + fired event) and rewrite activation tests to await an observable restart signal instead of counting macrotasks; cover the pinned-interpreter path. - Revert incidental package-lock.json peer-drift, keeping only the version bump. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for the thorough review! Addressed in 4cb83cb:
|
|
Looks good. Note that most of the carried-over 'unresolved' findings no longer apply to this revision: the subscription is now a standalone |
Summary
Adds an opt-in
ToolConfig.refreshExtensionOnPackagesChangekey that restarts the language server whenever the active Python environment's package managers report a package change (install/uninstall). The behavior is wired through the shared activation logic and is off by default, so existing extensions are unaffected until they opt in.Changes
types.ts— new optionalToolConfig.refreshExtensionOnPackagesChangeboolean (defaults tofalse).activation.ts— when the key istrue,initializePythonis given a callback that restarts the language server (safeRunServer, same path as config/interpreter changes) on each package change.python.ts—IPythonApiexposes anonDidChangePackagessubscription. The newerms-python.python-environmentsadapter forwards the extension event; the legacyms-python.pythonadapter is a no-op since it does not emit package events. The automatic refresh wiring (the callback that restarts the server) stays internal to activation.activation.test.tscovers the enabled (callback restarts server) and disabled (no callback) paths;python.test.tsconfirmsinitializePythonaccepts the optional callback.Validation
npm run build— cleannpm test— 127 passing