You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: Open file browser at workspace root when selecting interpreter path (#25520)
## Problem
When users click "Enter interpreter path..." and then select "Find..."
to browse for a Python interpreter, the file browser dialog opens at the
user's home directory instead of the current workspace root. This
creates a frustrating experience when trying to navigate to virtual
environments (like `.venv`) or other interpreters located within the
project directory.

## Solution
Added the `defaultUri` parameter to the `showOpenDialog` call in the
`_enterOrBrowseInterpreterPath` method. This parameter is set to
`state.workspace`, which contains the current workspace folder URI when
a workspace is open.
```typescript
const uris = await this.applicationShell.showOpenDialog({
filters: this.platformService.isWindows ? filtersObject : undefined,
openLabel: InterpreterQuickPickList.browsePath.openButtonLabel,
canSelectMany: false,
title: InterpreterQuickPickList.browsePath.title,
defaultUri: state.workspace, // ← Added this line
});
```
## Impact
- **With workspace open:** File browser now opens at the workspace root
directory, making it easy to find `.venv` folders and project-specific
interpreters
- **Without workspace open:** Behavior unchanged - file browser opens at
the default location (typically user's home directory)
## Testing
- Updated all existing unit tests to include the new `defaultUri`
parameter in expected values
- Added new test case: "If `Browse...` option is selected with
workspace, file browser opens at workspace root"
- All 35 tests in the "Set Interpreter Command" suite pass ✅
Fixes issue where users expected the file browser to open in their
current project directory when browsing for interpreters, improving the
user experience when setting up virtual environments in VS Code.
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: eleanorjboyd <[email protected]>
0 commit comments