@@ -7,6 +7,7 @@ use bstr::ByteSlice;
77use fxhash:: { FxHashMap , FxHashSet } ;
88use glob:: optimize_patterns;
99use glob_match:: glob_match;
10+ use paths:: Path ;
1011use rayon:: prelude:: * ;
1112use std:: fs;
1213use std:: path:: PathBuf ;
@@ -18,6 +19,7 @@ pub mod cursor;
1819pub mod fast_skip;
1920pub mod glob;
2021pub mod parser;
22+ pub mod paths;
2123pub mod scanner;
2224
2325static SHOULD_TRACE : sync:: LazyLock < bool > = sync:: LazyLock :: new (
@@ -151,7 +153,8 @@ impl Scanner {
151153
152154 self . files
153155 . 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 ( ) )
155158 . collect ( )
156159 }
157160
@@ -257,9 +260,18 @@ impl Scanner {
257260 false
258261 } ) ;
259262
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+
260272 for path in auto_sources
261273 . iter ( )
262- . map ( |source| PathBuf :: from ( & source. base ) . join ( source. pattern . trim_end_matches ( "**/*" ) ) )
274+ . map ( |source| join_paths ( & source. base , & source. pattern ) )
263275 {
264276 // Insert a glob for the base path, so we can see new files/folders in the directory itself.
265277 self . globs . push ( GlobEntry {
@@ -292,7 +304,8 @@ impl Scanner {
292304 // match as well.
293305 //
294306 // 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+
296309 if !source. pattern . is_empty ( ) {
297310 full_pattern. push ( '/' ) ;
298311 full_pattern. push_str ( & source. pattern ) ;
@@ -314,7 +327,9 @@ impl Scanner {
314327 continue ;
315328 } ;
316329
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) {
318333 self . files . push ( file_path) ;
319334 }
320335 }
0 commit comments