Skip to content

Environments: synchronize the public active environment API - #26204

Draft
Eleanor Boyd (eleanorjboyd) wants to merge 2 commits into
microsoft:mainfrom
eleanorjboyd:agents/vscode-python-issue-1896
Draft

Eleanor Boyd (eleanorjboyd) wants to merge 2 commits into
microsoft:mainfrom
eleanorjboyd:agents/vscode-python-issue-1896

Conversation

@eleanorjboyd

Copy link
Copy Markdown
Member

Summary

  • route updateActiveEnvironmentPath() through the Python Environments extension when integration is enabled
  • seed getActiveEnvironmentPath() from the Environments extension last-known selection
  • keep the synchronous getter aligned after public API updates and native Environments selection events
  • preserve the existing configuration-backed behavior when integration is disabled

Why

Fixes microsoft/vscode-python-environments#1896. The public Python API currently reads and writes legacy configuration state while integrated run, debug, and terminal execution use the Python Environments extension selection state. This makes the reported selection diverge from the interpreter actually used.

Coordinated API addition: microsoft/vscode-python-environments#1898.

Validation

  • npx gulp prePublishNonBundle
  • TypeScript compile
  • npm run test:unittests -- --grep Python Environment API (23 passing)
  • ESLint on all changed TypeScript files

Route public environment selection through the Python Environments extension when integration is enabled, and keep the synchronous getter aligned with its authoritative selection state.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines +81 to +84
export function getCachedEnvExtApi(): PythonEnvironmentApi | undefined {
return _extApi;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the getEnvExtApi which automatically returns cached _extApi?

Comment on lines +164 to +165
getWorkspaceFolders()?.forEach((folder) =>
cacheActiveEnvExtPath(folder.uri, envExtApi.getEnvironmentSync(folder.uri)),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getWorkspaceFolders()?.forEach((folder) =>
cacheActiveEnvExtPath(folder.uri, envExtApi.getEnvironmentSync(folder.uri)),
getWorkspaceFolders()?.forEach(({uri}) =>
cacheActiveEnvExtPath(uri, envExtApi.getEnvironmentSync(uri)),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python public environment API selection diverges from run/debug/terminal interpreter

2 participants