This repository was archived by the owner on May 20, 2026. It is now read-only.
Repository navigation
Handle absolute paths in search globs - #4287
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the inputGlobToPattern function in the search tools to properly handle absolute workspace folder paths in glob patterns, and adds support for multi-root workspace folder name detection. Previously, when an AI model provided an absolute filesystem path as a search pattern, it wasn't always correctly resolved to a scoped workspace folder pattern. The PR also enriches the return value with metadata (folder name, relative pattern) for improved display messages and telemetry.
Changes:
- Refactored
inputGlobToPatternto return anInputGlobResultobject (withpatterns,folderName,folderRelativePattern) and added logic to detect workspace folder names in multi-root workspaces (e.g.,folderName/src/**or**/folderName/...), plus a newpatternContainsWorkspaceFolderPathtelemetry helper. - Updated
FindFilesToolandFindTextInFilesToolto consume the newInputGlobResult, show folder-scoped display messages, send multi-root telemetry, and avoid corrupting absolute paths inresolveInput. - Updated model descriptions in
package.jsonto inform models about using absolute paths for scoping in multi-root workspaces.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/extension/tools/node/toolUtils.ts |
Core logic: new InputGlobResult type, folder name detection in multi-root workspaces, patternContainsWorkspaceFolderPath helper |
src/extension/tools/node/findTextInFilesTool.tsx |
Consumes InputGlobResult, adds telemetry, improved display formatting, prevents absolute path corruption in resolveInput |
src/extension/tools/node/findFilesTool.tsx |
Consumes InputGlobResult, adds telemetry, improved display formatting, prevents absolute path corruption in resolveInput |
package.json |
Updated model and parameter descriptions to mention absolute path scoping for multi-root workspaces |
src/extension/tools/node/test/toolUtils.spec.ts |
Unit tests for inputGlobToPattern covering multi-root, absolute paths, folder name detection, and edge cases |
src/extension/tools/node/test/findTextInFilesTool.spec.tsx |
Tests for absolute workspace folder path handling in FindTextInFilesTool, updated TestSearchService comparison logic |
src/extension/tools/node/test/findFiles.spec.tsx |
Tests for absolute workspace folder path handling in FindFilesTool, new RecordingFindFilesSearchService |
src/extension/tools/vscode-node/test/inputGlobToPattern.test.ts |
Integration tests for inputGlobToPattern with a real VS Code workspace |
roblourens
marked this pull request as ready for review
March 9, 2026 22:15
roblourens
enabled auto-merge
March 9, 2026 22:15
Matt Bierner (mjbvz)
approved these changes
Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix microsoft/vscode#292754
Fix microsoft/vscode#293428