@@ -88,7 +88,7 @@ interface Array<T> {}`
8888 }
8989
9090 interface Folder extends FSEntry {
91- entries : FSEntry [ ] ;
91+ entries : SortedArray < FSEntry > ;
9292 }
9393
9494 interface SymLink extends FSEntry {
@@ -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 ( ) ;
@@ -310,28 +312,31 @@ interface Array<T> {}`
310312 const watchDirectory : HostWatchDirectory = ( directory , cb ) => this . watchFile ( directory , ( ) => cb ( directory ) , PollingInterval . Medium ) ;
311313 this . customRecursiveWatchDirectory = createRecursiveDirectoryWatcher ( {
312314 directoryExists : path => this . directoryExists ( path ) ,
313- getAccessileSortedChildDirectories : path => this . getDirectories ( path ) ,
315+ getAccessibleSortedChildDirectories : path => this . getDirectories ( path ) ,
314316 filePathComparer : this . useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive ,
315- watchDirectory
317+ watchDirectory,
318+ realpath : s => this . realpath ( s )
316319 } ) ;
317320 }
318321 else if ( tscWatchDirectory === Tsc_WatchDirectory . NonRecursiveWatchDirectory ) {
319322 const watchDirectory : HostWatchDirectory = ( directory , cb ) => this . watchDirectory ( directory , fileName => cb ( fileName ) , /*recursive*/ false ) ;
320323 this . customRecursiveWatchDirectory = createRecursiveDirectoryWatcher ( {
321324 directoryExists : path => this . directoryExists ( path ) ,
322- getAccessileSortedChildDirectories : path => this . getDirectories ( path ) ,
325+ getAccessibleSortedChildDirectories : path => this . getDirectories ( path ) ,
323326 filePathComparer : this . useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive ,
324- watchDirectory
327+ watchDirectory,
328+ realpath : s => this . realpath ( s )
325329 } ) ;
326330 }
327331 else if ( tscWatchDirectory === Tsc_WatchDirectory . DynamicPolling ) {
328332 const watchFile = createDynamicPriorityPollingWatchFile ( this ) ;
329333 const watchDirectory : HostWatchDirectory = ( directory , cb ) => watchFile ( directory , ( ) => cb ( directory ) , PollingInterval . Medium ) ;
330334 this . customRecursiveWatchDirectory = createRecursiveDirectoryWatcher ( {
331335 directoryExists : path => this . directoryExists ( path ) ,
332- getAccessileSortedChildDirectories : path => this . getDirectories ( path ) ,
336+ getAccessibleSortedChildDirectories : path => this . getDirectories ( path ) ,
333337 filePathComparer : this . useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive ,
334- watchDirectory
338+ watchDirectory,
339+ realpath : s => this . realpath ( s )
335340 } ) ;
336341 }
337342 }
@@ -355,6 +360,11 @@ interface Array<T> {}`
355360 return s ;
356361 }
357362
363+ private now ( ) {
364+ this . time += timeIncrements ;
365+ return new Date ( this . time ) ;
366+ }
367+
358368 reloadFS ( fileOrFolderList : ReadonlyArray < FileOrFolder > , options ?: Partial < ReloadWatchInvokeOptions > ) {
359369 const mapNewLeaves = createMap < true > ( ) ;
360370 const isNewFs = this . fs . size === 0 ;
@@ -381,8 +391,8 @@ interface Array<T> {}`
381391 }
382392 else {
383393 currentEntry . content = fileOrDirectory . content ;
384- currentEntry . modifiedTime = new Date ( ) ;
385- this . fs . get ( getDirectoryPath ( currentEntry . path ) ) . modifiedTime = new Date ( ) ;
394+ currentEntry . modifiedTime = this . now ( ) ;
395+ this . fs . get ( getDirectoryPath ( currentEntry . path ) ) . modifiedTime = this . now ( ) ;
386396 if ( options && options . invokeDirectoryWatcherInsteadOfFileChanged ) {
387397 this . invokeDirectoryWatcher ( getDirectoryPath ( currentEntry . fullPath ) , currentEntry . fullPath ) ;
388398 }
@@ -406,7 +416,7 @@ interface Array<T> {}`
406416 }
407417 else {
408418 // Folder update: Nothing to do.
409- currentEntry . modifiedTime = new Date ( ) ;
419+ currentEntry . modifiedTime = this . now ( ) ;
410420 }
411421 }
412422 }
@@ -512,8 +522,8 @@ interface Array<T> {}`
512522 }
513523
514524 private addFileOrFolderInFolder ( folder : Folder , fileOrDirectory : File | Folder | SymLink , ignoreWatch ?: boolean ) {
515- folder . entries . push ( fileOrDirectory ) ;
516- folder . modifiedTime = new Date ( ) ;
525+ insertSorted ( folder . entries , fileOrDirectory , ( a , b ) => compareStringsCaseSensitive ( getBaseFileName ( a . path ) , getBaseFileName ( b . path ) ) ) ;
526+ folder . modifiedTime = this . now ( ) ;
517527 this . fs . set ( fileOrDirectory . path , fileOrDirectory ) ;
518528
519529 if ( ignoreWatch ) {
@@ -528,7 +538,7 @@ interface Array<T> {}`
528538 const baseFolder = this . fs . get ( basePath ) as Folder ;
529539 if ( basePath !== fileOrDirectory . path ) {
530540 Debug . assert ( ! ! baseFolder ) ;
531- baseFolder . modifiedTime = new Date ( ) ;
541+ baseFolder . modifiedTime = this . now ( ) ;
532542 filterMutate ( baseFolder . entries , entry => entry !== fileOrDirectory ) ;
533543 }
534544 this . fs . delete ( fileOrDirectory . path ) ;
@@ -603,7 +613,7 @@ interface Array<T> {}`
603613 return {
604614 path : this . toPath ( fullPath ) ,
605615 fullPath,
606- modifiedTime : new Date ( )
616+ modifiedTime : this . now ( )
607617 } ;
608618 }
609619
@@ -622,7 +632,7 @@ interface Array<T> {}`
622632
623633 private toFolder ( path : string ) : Folder {
624634 const folder = this . toFsEntry ( path ) as Folder ;
625- folder . entries = [ ] ;
635+ folder . entries = [ ] as SortedArray < FSEntry > ;
626636 return folder ;
627637 }
628638
@@ -642,7 +652,7 @@ interface Array<T> {}`
642652
643653 const realpath = this . realpath ( path ) ;
644654 if ( path !== realpath ) {
645- return this . getRealFsEntry ( isFsEntry , realpath as Path ) ;
655+ return this . getRealFsEntry ( isFsEntry , this . toPath ( realpath ) ) ;
646656 }
647657
648658 return undefined ;
0 commit comments