overhaul interpreter selection prioritization code to align with desired UX #1155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements a robust priority chain for interpreter selection that respects user-configured settings, fixes multi-root workspace issues, and prevents unwanted settings.json modifications on startup.
Changes
New Priority Chain (in order):
pythonProjects[]- Project-specific settings (highest priority)defaultEnvManager- User-configured only (not fallback values)python.defaultInterpreterPath- Legacy setting supportKey Fixes:
python.defaultInterpreterPathis now respected when no explicitdefaultEnvManageris configuredsettings.jsonwrites on workspace open (only on explicit user actions)How Cache Fits In
The cache stores previously resolved environments to avoid re-running discovery on every request.
Important: User-configured settings always take priority over cache. The cache is only used as a fallback when:
No user explicitly configured any of the above settings, AND
An environment was previously resolved for that scope
On workspace open, the full priority chain runs fresh for each folder. Cache is populated but not written to settings.json unless the user explicitly selects an interpreter.
Fixes #1145
Fixes #833
Fixes #1124
Testing
29 unit tests covering priority chain, config change listener, multi-root workspaces, and caching behavio