Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Handle absolute paths in search globs - #4287

Merged
roblourens merged 7 commits into
mainfrom
roblou/multiroot-search
Mar 10, 2026
Merged

roblourens merged 7 commits into
mainfrom
roblou/multiroot-search

Conversation

@roblourens

@roblourens roblourens commented Mar 9, 2026 •

Copy link
Copy Markdown
Member

@roblourens roblourens self-assigned this Mar 9, 2026
@roblourens
roblourens requested a review from Copilot March 9, 2026 04:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 inputGlobToPattern to return an InputGlobResult object (with patterns, folderName, folderRelativePattern) and added logic to detect workspace folder names in multi-root workspaces (e.g., folderName/src/** or **/folderName/...), plus a new patternContainsWorkspaceFolderPath telemetry helper.
  • Updated FindFilesTool and FindTextInFilesTool to consume the new InputGlobResult, show folder-scoped display messages, send multi-root telemetry, and avoid corrupting absolute paths in resolveInput.
  • Updated model descriptions in package.json to 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

Comment thread package.json Resolved
@roblourens
roblourens marked this pull request as ready for review March 9, 2026 22:15
@roblourens
roblourens enabled auto-merge March 9, 2026 22:15
@vs-code-engineering vs-code-engineering Bot added this to the 1.112.0 milestone Mar 9, 2026
@roblourens
roblourens added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 9904021 Mar 10, 2026
19 checks passed
@roblourens
roblourens deleted the roblou/multiroot-search branch March 10, 2026 01:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

3 participants