@@ -276,12 +276,14 @@ interface Array<T> {}`
276
276
DynamicPolling = "RecursiveDirectoryUsingDynamicPriorityPolling"
277
277
}
278
278
279
+ const timeIncrements = 1000 ;
279
280
export class TestServerHost implements server . ServerHost , FormatDiagnosticsHost , ModuleResolutionHost {
280
281
args : string [ ] = [ ] ;
281
282
282
283
private readonly output : string [ ] = [ ] ;
283
284
284
285
private fs : Map < FSEntry > = createMap < FSEntry > ( ) ;
286
+ private time = timeIncrements ;
285
287
getCanonicalFileName : ( s : string ) => string ;
286
288
private toPath : ( f : string ) => Path ;
287
289
private timeoutCallbacks = new Callbacks ( ) ;
@@ -355,6 +357,11 @@ interface Array<T> {}`
355
357
return s ;
356
358
}
357
359
360
+ private now ( ) {
361
+ this . time += timeIncrements ;
362
+ return new Date ( this . time ) ;
363
+ }
364
+
358
365
reloadFS ( fileOrFolderList : ReadonlyArray < FileOrFolder > , options ?: Partial < ReloadWatchInvokeOptions > ) {
359
366
const mapNewLeaves = createMap < true > ( ) ;
360
367
const isNewFs = this . fs . size === 0 ;
@@ -381,8 +388,8 @@ interface Array<T> {}`
381
388
}
382
389
else {
383
390
currentEntry . content = fileOrDirectory . content ;
384
- currentEntry . modifiedTime = new Date ( ) ;
385
- this . fs . get ( getDirectoryPath ( currentEntry . path ) ) . modifiedTime = new Date ( ) ;
391
+ currentEntry . modifiedTime = this . now ( ) ;
392
+ this . fs . get ( getDirectoryPath ( currentEntry . path ) ) . modifiedTime = this . now ( ) ;
386
393
if ( options && options . invokeDirectoryWatcherInsteadOfFileChanged ) {
387
394
this . invokeDirectoryWatcher ( getDirectoryPath ( currentEntry . fullPath ) , currentEntry . fullPath ) ;
388
395
}
@@ -406,7 +413,7 @@ interface Array<T> {}`
406
413
}
407
414
else {
408
415
// Folder update: Nothing to do.
409
- currentEntry . modifiedTime = new Date ( ) ;
416
+ currentEntry . modifiedTime = this . now ( ) ;
410
417
}
411
418
}
412
419
}
@@ -505,7 +512,7 @@ interface Array<T> {}`
505
512
506
513
private addFileOrFolderInFolder ( folder : Folder , fileOrDirectory : File | Folder | SymLink , ignoreWatch ?: boolean ) {
507
514
insertSorted ( folder . entries , fileOrDirectory , ( a , b ) => compareStringsCaseSensitive ( getBaseFileName ( a . path ) , getBaseFileName ( b . path ) ) ) ;
508
- folder . modifiedTime = new Date ( ) ;
515
+ folder . modifiedTime = this . now ( ) ;
509
516
this . fs . set ( fileOrDirectory . path , fileOrDirectory ) ;
510
517
511
518
if ( ignoreWatch ) {
@@ -520,7 +527,7 @@ interface Array<T> {}`
520
527
const baseFolder = this . fs . get ( basePath ) as Folder ;
521
528
if ( basePath !== fileOrDirectory . path ) {
522
529
Debug . assert ( ! ! baseFolder ) ;
523
- baseFolder . modifiedTime = new Date ( ) ;
530
+ baseFolder . modifiedTime = this . now ( ) ;
524
531
filterMutate ( baseFolder . entries , entry => entry !== fileOrDirectory ) ;
525
532
}
526
533
this . fs . delete ( fileOrDirectory . path ) ;
@@ -587,7 +594,7 @@ interface Array<T> {}`
587
594
return {
588
595
path : this . toPath ( fullPath ) ,
589
596
fullPath,
590
- modifiedTime : new Date ( )
597
+ modifiedTime : this . now ( )
591
598
} ;
592
599
}
593
600
0 commit comments