Skip to content

Commit 3f2ff01

Browse files
authored
Merge pull request microsoft#22450 from Microsoft/reenableTest
Enable the commented out test and convert folder entries to sorted list
2 parents ac5a39c + a0cd8d3 commit 3f2ff01

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/compiler/factory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ namespace ts {
2424
* Make `elements` into a `NodeArray<T>`. If `elements` is `undefined`, returns an empty `NodeArray<T>`.
2525
*/
2626
export function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T> {
27-
if (elements) {
27+
if (!elements || elements === emptyArray) {
28+
elements = [];
29+
}
30+
else {
2831
if (isNodeArray(elements)) {
2932
return elements;
3033
}
3134
}
32-
else {
33-
elements = [];
34-
}
3535

3636
const array = <NodeArray<T>>elements;
3737
array.pos = -1;

src/harness/unittests/tscWatchMode.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,9 +2333,9 @@ declare module "fs" {
23332333
verifyRenamingFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.NonRecursiveWatchDirectory);
23342334
});
23352335

2336-
// it("uses non recursive dynamic polling when renaming file in subfolder", () => {
2337-
// verifyRenamingFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.DynamicPolling);
2338-
// });
2336+
it("uses non recursive dynamic polling when renaming file in subfolder", () => {
2337+
verifyRenamingFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.DynamicPolling);
2338+
});
23392339
});
23402340
});
23412341
}

src/harness/virtualFileSystemWithWatch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {
@@ -504,7 +504,7 @@ interface Array<T> {}`
504504
}
505505

506506
private addFileOrFolderInFolder(folder: Folder, fileOrDirectory: File | Folder | SymLink, ignoreWatch?: boolean) {
507-
folder.entries.push(fileOrDirectory);
507+
insertSorted(folder.entries, fileOrDirectory, (a, b) => compareStringsCaseSensitive(getBaseFileName(a.path), getBaseFileName(b.path)));
508508
folder.modifiedTime = new Date();
509509
this.fs.set(fileOrDirectory.path, fileOrDirectory);
510510

@@ -606,7 +606,7 @@ interface Array<T> {}`
606606

607607
private toFolder(path: string): Folder {
608608
const folder = this.toFsEntry(path) as Folder;
609-
folder.entries = [];
609+
folder.entries = [] as SortedArray<FSEntry>;
610610
return folder;
611611
}
612612

0 commit comments

Comments
 (0)