Fix workspace path resolution when glob-like segments exist in folder names #273519
+32
−29
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.


For problem details, please refer to this issue: #273517
The cause of this problem lies in the
expandSearchPathPatternsfunction in thesrc/vs/workbench/services/search/common/queryBuilder.tsfile. This function is responsible for converting the raw content entered by the user in the Include/Exclude text boxes into formal file paths.The specific problem is in this sub-function within
expandSearchPathPatterns:Before calling
this.expandOneSearchPathto get the real path, the file path has already been corrupted by thesplitGlobFromPathfunction.Here are two examples to illustrate. Before reading the examples, please check this issue for background information.
Example 1
If our
searchPathis./monorepo (dev), after being processed by thesplitGlobFromPathfunction, we get apathPortionwith the value'./'and aglobPortionwith the value'monorepo (dev)'.Consequently, in the
this.expandOneSearchPathfunction, because the passed parameter is'./', the Include parameter does not take effect, resulting in a search across all folders.Example 2
If our
searchPathis./apps/vscode (dev), after being processed by thesplitGlobFromPathfunction, we get apathPortionwith the value'./apps'and aglobPortionwith the value'vscode (dev)'.Since
'./apps'does not exist, an error is triggered. However, the folder./apps/vscode (dev)actually exists in the project.Solution
We move the processing of
splitGlobFromPathdown into thethis.expandOneSearchPathfunction. When checking ifsearchPathis a project folder path, we use the originalsearchPathfor the check instead of thepathPortiontrimmed bysplitGlobFromPath.