@@ -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
}
@@ -513,7 +520,7 @@ interface Array<T> {}`
513
520
514
521
private addFileOrFolderInFolder ( folder : Folder , fileOrDirectory : File | Folder | SymLink , ignoreWatch ?: boolean ) {
515
522
insertSorted ( folder . entries , fileOrDirectory , ( a , b ) => compareStringsCaseSensitive ( getBaseFileName ( a . path ) , getBaseFileName ( b . path ) ) ) ;
516
- folder . modifiedTime = new Date ( ) ;
523
+ folder . modifiedTime = this . now ( ) ;
517
524
this . fs . set ( fileOrDirectory . path , fileOrDirectory ) ;
518
525
519
526
if ( ignoreWatch ) {
@@ -528,7 +535,7 @@ interface Array<T> {}`
528
535
const baseFolder = this . fs . get ( basePath ) as Folder ;
529
536
if ( basePath !== fileOrDirectory . path ) {
530
537
Debug . assert ( ! ! baseFolder ) ;
531
- baseFolder . modifiedTime = new Date ( ) ;
538
+ baseFolder . modifiedTime = this . now ( ) ;
532
539
filterMutate ( baseFolder . entries , entry => entry !== fileOrDirectory ) ;
533
540
}
534
541
this . fs . delete ( fileOrDirectory . path ) ;
@@ -603,7 +610,7 @@ interface Array<T> {}`
603
610
return {
604
611
path : this . toPath ( fullPath ) ,
605
612
fullPath,
606
- modifiedTime : new Date ( )
613
+ modifiedTime : this . now ( )
607
614
} ;
608
615
}
609
616
0 commit comments