Skip to content

Commit 5a579bd

Browse files
committed
Glob matching fails to preserve some metadata (fix microsoft#146296)
1 parent 43d0483 commit 5a579bd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/vs/base/common/glob.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ function wrapRelativePattern(parsedPattern: ParsedStringPattern, arg2: string |
357357
return parsedPattern;
358358
}
359359

360-
return function (path, basename) {
360+
const wrappedPattern: ParsedStringPattern = function (path, basename) {
361361
if (!isEqualOrParent(path, arg2.base, !isLinux)) {
362362
// skip glob matching if `base` is not a parent of `path`
363363
return null;
@@ -368,6 +368,14 @@ function wrapRelativePattern(parsedPattern: ParsedStringPattern, arg2: string |
368368
// and only match on the remaining path components
369369
return parsedPattern(path.substr(arg2.base.length + 1), basename);
370370
};
371+
372+
// Make sure to preserve associated metadata
373+
wrappedPattern.allBasenames = parsedPattern.allBasenames;
374+
wrappedPattern.allPaths = parsedPattern.allPaths;
375+
wrappedPattern.basenames = parsedPattern.basenames;
376+
wrappedPattern.patterns = parsedPattern.patterns;
377+
378+
return wrappedPattern;
371379
}
372380

373381
function trimForExclusions(pattern: string, options: IGlobOptions): string {

0 commit comments

Comments
 (0)