-
Notifications
You must be signed in to change notification settings - Fork 36.8k
improve terminal completions relative path resolution #282861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalCompletionService.ts
Outdated
Show resolved
Hide resolved
Pull request was converted to draft
| { 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); |
There was a problem hiding this comment.
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/...
fixes #282458
fixes #282491
./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.URI.joinPath) and ensure it exists via stat; if not, we bail../s/segments.Also updated tests to align with the stricter resolution, including path normalization in the test stub and ensuring
CDPATHroots are marked as existing.