Skip to content

Fix #1599: onDidChangePythonProjects never fires on runtime project a…#1641

Open
mohityadav8 wants to merge 1 commit into
microsoft:mainfrom
mohityadav8:fix-ondidchange-python-projects-not-firing
Open

Fix #1599: onDidChangePythonProjects never fires on runtime project a…#1641
mohityadav8 wants to merge 1 commit into
microsoft:mainfrom
mohityadav8:fix-ondidchange-python-projects-not-firing

Conversation

@mohityadav8

@mohityadav8 mohityadav8 commented Jul 19, 2026

Copy link
Copy Markdown

Summary

Fixes #1599PythonEnvironmentApi.onDidChangePythonProjects never fired when projects were added or removed at runtime. The internal project list updated correctly, but the public event was never forwarded, so consumers (notably Pylance's per-folder interpreter support) never got notified and required a restart to pick up new projects.

Root cause

PythonEnvironmentApiImpl's constructor subscribed to environment-change events but never subscribed toprojectManager.onDidChangeProjects, so _onDidChangePythonProjects.fire(...) was never called.

Fix

  • Added a previousProjects field on PythonEnvironmentApiImpl that tracks the last-known project set.
  • Subscribed to projectManager.onDidChangeProjects in the constructor. On each internal change, compute the added/removed delta by diffing project URIs against the previous snapshot, update the snapshot, and fire _onDidChangePythonProjects with { added, removed } when the set actually changed.

Diffing by URI (rather than relying on the manager's internal eventpayload) was needed because the manager currently emits the full projectarray rather than a delta, and DidChangePythonProjectsEventArgs expectsadded/removed.

Testing

  • npm run compile — clean build.
  • Manually verified via getPythonProjects() that the set updates as expected; confirmed the new subscription fires on addPythonProject() and removePythonProject() calls.

@mohityadav8
mohityadav8 force-pushed the fix-ondidchange-python-projects-not-firing branch from 58e3d18 to 8798be4 Compare July 19, 2026 10:21
@mohityadav8
mohityadav8 marked this pull request as ready for review July 19, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Public onDidChangePythonProjects API event never fires (runtime project add/remove not reported to consumers)

1 participant