Skip to content

Glob matching fails to preserve some metadata #146296

@bpasero

Description

@bpasero

We seem to associate some metadata with a parsed glob pattern:

interface ParsedStringPattern {
(path: string, basename?: string): string | null | Promise<string | null> /* the matching pattern */;
basenames?: string[];
patterns?: string[];
allBasenames?: string[];
allPaths?: string[];
}
interface ParsedExpressionPattern {
(path: string, basename?: string, name?: string, hasSibling?: (name: string) => boolean | Promise<boolean>): string | null | Promise<string | null> /* the matching pattern */;
requiresSiblings?: boolean;
allBasenames?: string[];
allPaths?: string[];
}

But we then seem to miss re-applying these properties when wrapping for a relative pattern:

function wrapRelativePattern(parsedPattern: ParsedStringPattern, arg2: string | IRelativePattern): ParsedStringPattern {
if (typeof arg2 === 'string') {
return parsedPattern;
}
return function (path, basename) {
if (!isEqualOrParent(path, arg2.base, !isLinux)) {
// skip glob matching if `base` is not a parent of `path`
return null;
}
// Given we have checked `base` being a parent of `path`,
// we can now remove the `base` portion of the `path`
// and only match on the remaining path components
return parsedPattern(path.substr(arg2.base.length + 1), basename);
};
}

It is unclear to me what the consequences are, maybe you can check @chrmarti and I can look into the fix.

Metadata

Metadata

Labels

debtCode quality issuesfile-globFile glob engineinsiders-releasedPatch has been released in VS Code Insiders

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions