@@ -875,9 +875,11 @@ impl FakeFsState {
875
875
canonical_path. clear ( ) ;
876
876
match prefix {
877
877
Some ( prefix_component) => {
878
- canonical_path. push ( prefix_component. as_os_str ( ) ) ;
878
+ canonical_path = PathBuf :: from ( prefix_component. as_os_str ( ) ) ;
879
+ // Prefixes like `C:\\` are represented without their trailing slash, so we have to re-add it.
880
+ canonical_path. push ( std:: path:: MAIN_SEPARATOR_STR ) ;
879
881
}
880
- None => canonical_path. push ( "/" ) ,
882
+ None => canonical_path = PathBuf :: from ( std :: path :: MAIN_SEPARATOR_STR ) ,
881
883
}
882
884
}
883
885
Component :: CurDir => { }
@@ -900,7 +902,7 @@ impl FakeFsState {
900
902
}
901
903
}
902
904
entry_stack. push ( entry. clone ( ) ) ;
903
- canonical_path. push ( name) ;
905
+ canonical_path = canonical_path . join ( name) ;
904
906
} else {
905
907
return None ;
906
908
}
@@ -962,6 +964,10 @@ pub static FS_DOT_GIT: std::sync::LazyLock<&'static OsStr> =
962
964
963
965
#[ cfg( any( test, feature = "test-support" ) ) ]
964
966
impl FakeFs {
967
+ /// We need to use something large enough for Windows and Unix to consider this a new file.
968
+ /// https://doc.rust-lang.org/nightly/std/time/struct.SystemTime.html#platform-specific-behavior
969
+ const SYSTEMTIME_INTERVAL : u64 = 100 ;
970
+
965
971
pub fn new ( executor : gpui:: BackgroundExecutor ) -> Arc < Self > {
966
972
Arc :: new ( Self {
967
973
executor,
@@ -995,7 +1001,7 @@ impl FakeFs {
995
1001
let new_mtime = state. next_mtime ;
996
1002
let new_inode = state. next_inode ;
997
1003
state. next_inode += 1 ;
998
- state. next_mtime += Duration :: from_nanos ( 1 ) ;
1004
+ state. next_mtime += Duration :: from_nanos ( Self :: SYSTEMTIME_INTERVAL ) ;
999
1005
state
1000
1006
. write_path ( path, move |entry| {
1001
1007
match entry {
@@ -1048,7 +1054,7 @@ impl FakeFs {
1048
1054
let inode = state. next_inode ;
1049
1055
let mtime = state. next_mtime ;
1050
1056
state. next_inode += 1 ;
1051
- state. next_mtime += Duration :: from_nanos ( 1 ) ;
1057
+ state. next_mtime += Duration :: from_nanos ( Self :: SYSTEMTIME_INTERVAL ) ;
1052
1058
let file = Arc :: new ( Mutex :: new ( FakeFsEntry :: File {
1053
1059
inode,
1054
1060
mtime,
@@ -1399,7 +1405,7 @@ impl Fs for FakeFs {
1399
1405
1400
1406
let inode = state. next_inode ;
1401
1407
let mtime = state. next_mtime ;
1402
- state. next_mtime += Duration :: from_nanos ( 1 ) ;
1408
+ state. next_mtime += Duration :: from_nanos ( Self :: SYSTEMTIME_INTERVAL ) ;
1403
1409
state. next_inode += 1 ;
1404
1410
state. write_path ( & cur_path, |entry| {
1405
1411
entry. or_insert_with ( || {
@@ -1425,7 +1431,7 @@ impl Fs for FakeFs {
1425
1431
let mut state = self . state . lock ( ) ;
1426
1432
let inode = state. next_inode ;
1427
1433
let mtime = state. next_mtime ;
1428
- state. next_mtime += Duration :: from_nanos ( 1 ) ;
1434
+ state. next_mtime += Duration :: from_nanos ( Self :: SYSTEMTIME_INTERVAL ) ;
1429
1435
state. next_inode += 1 ;
1430
1436
let file = Arc :: new ( Mutex :: new ( FakeFsEntry :: File {
1431
1437
inode,
@@ -1560,7 +1566,7 @@ impl Fs for FakeFs {
1560
1566
let mut state = self . state . lock ( ) ;
1561
1567
let mtime = state. next_mtime ;
1562
1568
let inode = util:: post_inc ( & mut state. next_inode ) ;
1563
- state. next_mtime += Duration :: from_nanos ( 1 ) ;
1569
+ state. next_mtime += Duration :: from_nanos ( Self :: SYSTEMTIME_INTERVAL ) ;
1564
1570
let source_entry = state. read_path ( & source) ?;
1565
1571
let content = source_entry. lock ( ) . file_content ( & source) ?. clone ( ) ;
1566
1572
let mut kind = Some ( PathEventKind :: Created ) ;
0 commit comments