@@ -7,6 +7,7 @@ use bstr::ByteSlice;
7
7
use fxhash:: { FxHashMap , FxHashSet } ;
8
8
use glob:: optimize_patterns;
9
9
use glob_match:: glob_match;
10
+ use paths:: Path ;
10
11
use rayon:: prelude:: * ;
11
12
use std:: fs;
12
13
use std:: path:: PathBuf ;
@@ -18,6 +19,7 @@ pub mod cursor;
18
19
pub mod fast_skip;
19
20
pub mod glob;
20
21
pub mod parser;
22
+ pub mod paths;
21
23
pub mod scanner;
22
24
23
25
static SHOULD_TRACE : sync:: LazyLock < bool > = sync:: LazyLock :: new (
@@ -151,7 +153,8 @@ impl Scanner {
151
153
152
154
self . files
153
155
. iter ( )
154
- . map ( |x| x. to_string_lossy ( ) . into ( ) )
156
+ . filter_map ( |x| Path :: from ( x. clone ( ) ) . canonicalize ( ) . ok ( ) )
157
+ . map ( |x| x. to_string ( ) )
155
158
. collect ( )
156
159
}
157
160
@@ -257,9 +260,18 @@ impl Scanner {
257
260
false
258
261
} ) ;
259
262
263
+ fn join_paths ( a : & str , b : & str ) -> PathBuf {
264
+ let mut tmp = a. to_owned ( ) ;
265
+
266
+ tmp += "/" ;
267
+ tmp += b. trim_end_matches ( "**/*" ) . trim_end_matches ( '/' ) ;
268
+
269
+ PathBuf :: from ( & tmp)
270
+ }
271
+
260
272
for path in auto_sources
261
273
. iter ( )
262
- . map ( |source| PathBuf :: from ( & source. base ) . join ( source. pattern . trim_end_matches ( "**/*" ) ) )
274
+ . map ( |source| join_paths ( & source. base , & source. pattern ) )
263
275
{
264
276
// Insert a glob for the base path, so we can see new files/folders in the directory itself.
265
277
self . globs . push ( GlobEntry {
@@ -292,7 +304,8 @@ impl Scanner {
292
304
// match as well.
293
305
//
294
306
// Instead we combine the base and the pattern as a single glob pattern.
295
- let mut full_pattern = source. base . clone ( ) ;
307
+ let mut full_pattern = source. base . clone ( ) . replace ( '\\' , "/" ) ;
308
+
296
309
if !source. pattern . is_empty ( ) {
297
310
full_pattern. push ( '/' ) ;
298
311
full_pattern. push_str ( & source. pattern ) ;
@@ -314,7 +327,9 @@ impl Scanner {
314
327
continue ;
315
328
} ;
316
329
317
- if glob_match ( & full_pattern, file_path_str) {
330
+ let file_path_str = file_path_str. replace ( '\\' , "/" ) ;
331
+
332
+ if glob_match ( & full_pattern, & file_path_str) {
318
333
self . files . push ( file_path) ;
319
334
}
320
335
}
0 commit comments