Skip to content

Comments

feat: add disambiguation suffixes for Python environments in env manager#1197

Merged
eleanorjboyd merged 3 commits intomicrosoft:mainfrom
eleanorjboyd:puzzled-cougar
Feb 6, 2026
Merged

feat: add disambiguation suffixes for Python environments in env manager#1197
eleanorjboyd merged 3 commits intomicrosoft:mainfrom
eleanorjboyd:puzzled-cougar

Conversation

@eleanorjboyd
Copy link
Member

fixes #1196

@eleanorjboyd eleanorjboyd added the feature-request Request for new features or functionality label Feb 6, 2026
@eleanorjboyd eleanorjboyd self-assigned this Feb 6, 2026
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 6, 2026
@eleanorjboyd eleanorjboyd enabled auto-merge (squash) February 6, 2026 01:23
@eleanorjboyd eleanorjboyd merged commit 10f3105 into microsoft:main Feb 6, 2026
7 checks passed
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

This PR adds disambiguation suffixes to Python environment tree items when multiple environments share the same base name. The feature helps users distinguish between similarly-named virtual environments (e.g., multiple .venv folders) by displaying their parent folder names in the description field.

Changes:

  • Introduced getEnvironmentParentDirName function to extract parent folder names from environment paths
  • Added computeDisambiguationSuffixes to identify environments needing disambiguation and compute their suffixes
  • Updated PythonEnvTreeItem to accept and display disambiguation suffixes in the description field

Reviewed changes

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

File Description
src/features/views/treeViewItems.ts Added getEnvironmentParentDirName function and updated PythonEnvTreeItem constructor to support disambiguation suffixes
src/features/views/envManagersView.ts Added getBaseName and computeDisambiguationSuffixes functions; integrated disambiguation logic into tree view rendering
src/test/features/views/treeViewItems.unit.test.ts Added comprehensive test coverage for disambiguation suffix functionality and refactored existing tests with helper functions

Comment on lines +31 to +32
if (part.startsWith('python')) {
continue;
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The logic for identifying venv folders relies on checking if a part starts with 'python', but this could incorrectly skip legitimate folder names that start with 'python' (e.g., 'python-utils', 'python_project'). Consider making this check more specific by checking for exact matches with common Python executable names like 'python', 'python3', 'python.exe', etc.

Copilot uses AI. Check for mistakes.
* @example getBaseName('myenv (3.14.1)') returns 'myenv'
*/
function getBaseName(displayName: string): string {
return displayName.replace(/\s*\([0-9.]+\)\s*$/, '').trim();
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The regex pattern [0-9.]+ could match invalid version strings like '3..12' or '...'. Consider using a more precise pattern like [0-9]+(?:\\.[0-9]+)* to match valid semantic version formats.

Suggested change
return displayName.replace(/\s*\([0-9.]+\)\s*$/, '').trim();
return displayName.replace(/\s*\([0-9]+(?:\.[0-9]+)*\)\s*$/, '').trim();

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

feature-request Request for new features or functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

disambiguation suffixes for Python environments in env manager

2 participants