@@ -18,6 +18,11 @@ export class FileSearchProvider implements vscode.FileSearchProvider {
18
18
) : Promise < vscode . Uri [ ] > {
19
19
let counter = 0 ;
20
20
let pattern = query . pattern . charAt ( 0 ) == "/" ? query . pattern . slice ( 1 ) : query . pattern ;
21
+
22
+ // Drop a leading **/ from the glob pattern if it exists (added by Find widget of Explorer tree, which since 1.94 uses FileSearchProvider)
23
+ if ( pattern . startsWith ( "**/" ) ) {
24
+ pattern = pattern . slice ( 3 ) ;
25
+ }
21
26
const params = new URLSearchParams ( options . folder . query ) ;
22
27
const csp = params . has ( "csp" ) && [ "" , "1" ] . includes ( params . get ( "csp" ) ) ;
23
28
if ( params . has ( "project" ) && params . get ( "project" ) . length ) {
@@ -44,13 +49,17 @@ export class FileSearchProvider implements vscode.FileSearchProvider {
44
49
// When this is called without a query.pattern, every file is supposed to be returned, so do not provide a filter
45
50
let filter = "" ;
46
51
if ( pattern . length ) {
47
- pattern = ! csp ? query . pattern . replace ( / \/ / g, "." ) : query . pattern ;
52
+ let escapeClause = "" ;
53
+ pattern = ! csp ? pattern . replace ( / \/ / g, "." ) : pattern ;
48
54
if ( pattern . includes ( "_" ) || pattern . includes ( "%" ) ) {
49
55
// Need to escape any % or _ characters
50
- filter = `Name LIKE '%${ pattern . replace ( / ( _ | % | \\ ) / g, "\\$1" ) } %' ESCAPE '\\'` ;
51
- } else {
52
- filter = `Name LIKE '%${ pattern } %'` ;
56
+ pattern = pattern . replace ( / ( _ | % | \\ ) / g, "\\$1" ) ;
57
+ escapeClause = " ESCAPE '\\'" ;
53
58
}
59
+ // Change glob syntax to SQL LIKE syntax
60
+ pattern = pattern . replace ( / \* / g, "%" ) ;
61
+ pattern = pattern . replace ( / \? / g, "_" ) ;
62
+ filter = `Name LIKE '%${ pattern } %'${ escapeClause } ` ;
54
63
}
55
64
if ( token . isCancellationRequested ) {
56
65
return ;
0 commit comments