提交 70c10c91 编写于 作者: R Rob Lourens

Fix #26634 - if a `./` include pattern contains glob characters, ignore the `./`

上级 31aaf875
......@@ -110,8 +110,6 @@ export class PatternInputWidget extends Widget {
return {};
}
const isSearchPath = segment => segment.match(/^\.\//);
let exprSegments: string[];
let searchPaths: string[];
if (isGlobPattern) {
......@@ -119,21 +117,17 @@ export class PatternInputWidget extends Widget {
.map(s => s.trim())
.filter(s => !!s.length);
const groups = collections.groupBy(segments,
segment => isSearchPath(segment) ? 'searchPaths' : 'exprSegments');
searchPaths = groups.searchPaths || [];
exprSegments = groups.exprSegments || [];
const groups = this.groupByPathsAndExprSegments(segments);
searchPaths = groups.searchPaths;
exprSegments = groups.exprSegments;
} else {
const segments = pattern.split(',')
.map(s => strings.trim(s.trim(), '/'))
.filter(s => !!s.length);
const groups = collections.groupBy(segments,
segment => isSearchPath(segment) ? 'searchPaths' : 'exprSegments');
searchPaths = groups.searchPaths || [];
exprSegments = groups.exprSegments || [];
exprSegments = exprSegments
const groups = this.groupByPathsAndExprSegments(segments);
searchPaths = groups.searchPaths;
exprSegments = groups.exprSegments
.map(p => {
if (p[0] === '.') {
p = '*' + p; // convert ".js" to "*.js"
......@@ -147,6 +141,27 @@ export class PatternInputWidget extends Widget {
return { expression, searchPaths };
}
private groupByPathsAndExprSegments(segments: string[]) {
const isSearchPath = segment => segment.match(/^\.\//);
const groups = collections.groupBy(segments,
segment => isSearchPath(segment) ? 'searchPaths' : 'exprSegments');
groups.searchPaths = groups.searchPaths || [];
groups.exprSegments = groups.exprSegments || [];
// If a ./searchPath has a glob character, remove ./ and use it as an expression segment
groups.searchPaths = groups.searchPaths.filter(searchPath => {
if (searchPath.match(/[\*\{\}\(\)\[\]\?]/)) {
groups.exprSegments.push(strings.ltrim(searchPath, './'));
return false;
}
return true;
});
return groups;
}
public select(): void {
this.inputBox.select();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册