@@ -276,12 +276,14 @@ interface Array<T> {}`
276276 DynamicPolling = "RecursiveDirectoryUsingDynamicPriorityPolling"
277277 }
278278
279+ const timeIncrements = 1000 ;
279280 export class TestServerHost implements server . ServerHost , FormatDiagnosticsHost , ModuleResolutionHost {
280281 args : string [ ] = [ ] ;
281282
282283 private readonly output : string [ ] = [ ] ;
283284
284285 private fs : Map < FSEntry > = createMap < FSEntry > ( ) ;
286+ private time = timeIncrements ;
285287 getCanonicalFileName : ( s : string ) => string ;
286288 private toPath : ( f : string ) => Path ;
287289 private timeoutCallbacks = new Callbacks ( ) ;
@@ -355,6 +357,11 @@ interface Array<T> {}`
355357 return s ;
356358 }
357359
360+ private now ( ) {
361+ this . time += timeIncrements ;
362+ return new Date ( this . time ) ;
363+ }
364+
358365 reloadFS ( fileOrFolderList : ReadonlyArray < FileOrFolder > , options ?: Partial < ReloadWatchInvokeOptions > ) {
359366 const mapNewLeaves = createMap < true > ( ) ;
360367 const isNewFs = this . fs . size === 0 ;
@@ -381,8 +388,8 @@ interface Array<T> {}`
381388 }
382389 else {
383390 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 ( ) ;
386393 if ( options && options . invokeDirectoryWatcherInsteadOfFileChanged ) {
387394 this . invokeDirectoryWatcher ( getDirectoryPath ( currentEntry . fullPath ) , currentEntry . fullPath ) ;
388395 }
@@ -406,7 +413,7 @@ interface Array<T> {}`
406413 }
407414 else {
408415 // Folder update: Nothing to do.
409- currentEntry . modifiedTime = new Date ( ) ;
416+ currentEntry . modifiedTime = this . now ( ) ;
410417 }
411418 }
412419 }
@@ -505,7 +512,7 @@ interface Array<T> {}`
505512
506513 private addFileOrFolderInFolder ( folder : Folder , fileOrDirectory : File | Folder | SymLink , ignoreWatch ?: boolean ) {
507514 insertSorted ( folder . entries , fileOrDirectory , ( a , b ) => compareStringsCaseSensitive ( getBaseFileName ( a . path ) , getBaseFileName ( b . path ) ) ) ;
508- folder . modifiedTime = new Date ( ) ;
515+ folder . modifiedTime = this . now ( ) ;
509516 this . fs . set ( fileOrDirectory . path , fileOrDirectory ) ;
510517
511518 if ( ignoreWatch ) {
@@ -520,7 +527,7 @@ interface Array<T> {}`
520527 const baseFolder = this . fs . get ( basePath ) as Folder ;
521528 if ( basePath !== fileOrDirectory . path ) {
522529 Debug . assert ( ! ! baseFolder ) ;
523- baseFolder . modifiedTime = new Date ( ) ;
530+ baseFolder . modifiedTime = this . now ( ) ;
524531 filterMutate ( baseFolder . entries , entry => entry !== fileOrDirectory ) ;
525532 }
526533 this . fs . delete ( fileOrDirectory . path ) ;
@@ -587,7 +594,7 @@ interface Array<T> {}`
587594 return {
588595 path : this . toPath ( fullPath ) ,
589596 fullPath,
590- modifiedTime : new Date ( )
597+ modifiedTime : this . now ( )
591598 } ;
592599 }
593600
0 commit comments