Skip to content

Choose project for terminal#1401

Draft
edvilme wants to merge 1 commit intomainfrom
multiroot-terminal
Draft

Choose project for terminal#1401
edvilme wants to merge 1 commit intomainfrom
multiroot-terminal

Conversation

@edvilme
Copy link
Contributor

@edvilme edvilme commented Mar 26, 2026

Fixes #291

@edvilme edvilme added area-terminal Environment extension specific terminal issues. bug Issue identified by VS Code Team member as probable bug labels Mar 26, 2026
@edvilme edvilme requested review from Copilot and eleanorjboyd March 26, 2026 05:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the Python: Create Terminal command behavior to better support multi-root workspaces by selecting an appropriate Python project before creating a terminal.

Changes:

  • Cache api.getPythonProjects() and reuse it during terminal creation.
  • Update the project-picking flow in createTerminalCommand.
  • Update package-lock.json with additional peer metadata entries.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/features/envCommands.ts Updates project selection logic used when creating terminals.
package-lock.json Adds peer: true metadata to multiple dependency entries.

if (context === undefined) {
const pw = await pickProject(api.getPythonProjects());
const pythonProjects = api.getPythonProjects();
if (context === undefined || pythonProjects.length > 0) {
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The if (context === undefined || pythonProjects.length > 0) condition makes all subsequent else if branches effectively unreachable whenever there is at least one Python project. This causes the command to ignore the provided context (e.g., Uri/ProjectItem/PythonEnvTreeItem) and can create a terminal for a different environment/project than the one the user invoked the command on. Consider restoring the context-based branching (only enter the project-pick flow when context is undefined, or when you explicitly need to disambiguate between multiple projects) so that Uri/ProjectItem/PythonEnvTreeItem cases still behave correctly.

Suggested change
if (context === undefined || pythonProjects.length > 0) {
if (context === undefined) {

Copilot uses AI. Check for mistakes.
import { executeCommand } from '../common/command.api';
import { clipboardWriteText } from '../common/env.apis';
import {} from '../common/errors/utils';
import { } from '../common/errors/utils';
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

This is an empty named import (import { } from ...) and the target module only exports helpers (no side effects). This should be removed (or replaced with a side-effect-only import if a side effect is actually required) to avoid dead/unused imports.

Suggested change
import { } from '../common/errors/utils';

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-terminal Environment extension specific terminal issues. 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: Create Terminal' doesn't consider multiroot option

2 participants