Skip to content

Conversation

@meganrogge
Copy link
Contributor

@meganrogge meganrogge commented Dec 11, 2025

fixes #282458
fixes #282491

  • For relative paths with content (./src/vs/), we first normalize separators/escapes and check whether that trailing segment already matches the end of cwd. This catches cases where the extension already resolved the path so we avoid re-appending segments (prevents ./src/src/... duplicates). We stat cwd to be sure it exists.
  • If that reuse doesn’t apply, we resolve the normalized folder against cwd (URI.joinPath) and ensure it exists via stat; if not, we bail.
  • If the relative path is empty (e.g. cursor at start), we just use cwd.
  • This makes resource completions consistent whether the extension pre-resolved the path or not, and prevents showing phantom paths like duplicated ./s/ segments.

Also updated tests to align with the stricter resolution, including path normalization in the test stub and ensuring CDPATH roots are marked as existing.

Copilot AI review requested due to automatic review settings December 11, 2025 20:14
@meganrogge meganrogge self-assigned this Dec 11, 2025
@meganrogge meganrogge requested a review from Tyriar December 11, 2025 20:15
@meganrogge meganrogge added this to the December / January 2026 milestone Dec 11, 2025
@meganrogge meganrogge enabled auto-merge (squash) December 11, 2025 20:15
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 fixes terminal path completion issues where relative folder prefixes were being resolved against the current working directory without validation, producing invalid suggestions like ./s/src/ when the intermediate path didn't exist.

Key Changes:

  • Added validation for relative folder prefixes before generating completions
  • Implemented special handling for the case where a typed folder name matches the cwd basename
  • Updated test infrastructure to properly handle path existence checks with trailing slash normalization

Reviewed changes

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

File Description
src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalCompletionService.ts Added validation logic to check if relative folder paths exist before attempting to generate completions, including special case handling for paths matching the cwd basename
src/vs/workbench/contrib/terminalContrib/suggest/test/browser/terminalCompletionService.test.ts Added path normalization helper, updated file service stub to check existence in resolve method, added test case for non-existent relative folders, and included CDPATH root in valid resources

@meganrogge meganrogge marked this pull request as draft December 12, 2025 16:28
auto-merge was automatically disabled December 12, 2025 16:28

Pull request was converted to draft

@meganrogge meganrogge marked this pull request as ready for review December 12, 2025 16:40
@meganrogge meganrogge enabled auto-merge (squash) December 12, 2025 16:40
@meganrogge meganrogge changed the title skip non-existent relative prefixes for terminal completions improve terminal completions relative path resolution Dec 12, 2025
{ resource: URI.parse('file:///test/folder2/'), isDirectory: true }
];
const result = await terminalCompletionService.resolveResources(resourceOptions, 'test/', 5, provider, capabilities);
const result = await terminalCompletionService.resolveResources(resourceOptions, './test/', 7, provider, capabilities);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was actually invalid before - when typing test/ within test folder, we shouldn't have been showing ./test/...

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal suggestions break after tabbing for suggestions git add showing non-existent folders

2 participants