File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
workbench/services/search/test/common Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -47,17 +47,18 @@ const PATH_REGEX = '[/\\\\]'; // any slash or backslash
47
47
const NO_PATH_REGEX = '[^/\\\\]' ; // any non-slash and non-backslash
48
48
const ALL_FORWARD_SLASHES = / \/ / g;
49
49
50
- function starsToRegExp ( starCount : number ) : string {
50
+ function starsToRegExp ( starCount : number , isLastPattern ?: boolean ) : string {
51
51
switch ( starCount ) {
52
52
case 0 :
53
53
return '' ;
54
54
case 1 :
55
55
return `${ NO_PATH_REGEX } *?` ; // 1 star matches any number of characters except path separator (/ and \) - non greedy (?)
56
56
default :
57
- // Matches: (Path Sep OR Path Val followed by Path Sep OR Path Sep followed by Path Val) 0-many times
57
+ // Matches: (Path Sep OR Path Val followed by Path Sep) 0-many times except when it's the last pattern
58
+ // in which case also matches (Path Sep followed by Path Val)
58
59
// Group is non capturing because we don't need to capture at all (?:...)
59
60
// Overall we use non-greedy matching because it could be that we match too much
60
- return `(?:${ PATH_REGEX } |${ NO_PATH_REGEX } +${ PATH_REGEX } |${ PATH_REGEX } ${ NO_PATH_REGEX } +)*?` ;
61
+ return `(?:${ PATH_REGEX } |${ NO_PATH_REGEX } +${ PATH_REGEX } ${ isLastPattern ? ` |${ PATH_REGEX } ${ NO_PATH_REGEX } +` : '' } )*?` ;
61
62
}
62
63
}
63
64
@@ -135,7 +136,7 @@ function parseRegExp(pattern: string): string {
135
136
return ;
136
137
}
137
138
138
- regEx += starsToRegExp ( 2 ) ;
139
+ regEx += starsToRegExp ( 2 , index === segments . length - 1 ) ;
139
140
}
140
141
141
142
// Anything else, not globstar
Original file line number Diff line number Diff line change @@ -725,7 +725,7 @@ suite('Glob', () => {
725
725
assert . strictEqual ( glob . match ( expr , 'foo.as' ) , null ) ;
726
726
} ) ;
727
727
728
- test . skip ( 'expression with non-trivia glob (issue 144458)' , function ( ) {
728
+ test ( 'expression with non-trivia glob (issue 144458)' , function ( ) {
729
729
let pattern = '**/p*' ;
730
730
731
731
assert . strictEqual ( glob . match ( pattern , 'foo/barp' ) , false ) ;
Original file line number Diff line number Diff line change @@ -477,7 +477,7 @@ suite('Parsing .gitignore files', () => {
477
477
} ) ;
478
478
479
479
runTest ( {
480
- pattern : `[._]*. s[a-w][a-z]
480
+ pattern : `[._]*s[a-w][a-z]
481
481
[._]s[a-w][a-z]
482
482
*.un~
483
483
*~` ,
You can’t perform that action at this time.
0 commit comments