Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the commented out test and convert folder entries to sorted list #22450

Merged
merged 2 commits into from
Mar 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/compiler/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ namespace ts {
* Make `elements` into a `NodeArray<T>`. If `elements` is `undefined`, returns an empty `NodeArray<T>`.
*/
export function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T> {
if (elements) {
if (!elements || elements === emptyArray) {
elements = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks concerning. Does this happen often? Did you catch the code path where this occurres?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did look for exact code path since they are multiple ones but remember seeing this with code fix related node creations being one of them. it was discovered as part of #22167 when code fix related tests would cause those module resolution tests to fail....

}
else {
if (isNodeArray(elements)) {
return elements;
}
}
else {
elements = [];
}

const array = <NodeArray<T>>elements;
array.pos = -1;
Expand Down
6 changes: 3 additions & 3 deletions src/harness/unittests/tscWatchMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2333,9 +2333,9 @@ declare module "fs" {
verifyRenamingFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.NonRecursiveWatchDirectory);
});

// it("uses non recursive dynamic polling when renaming file in subfolder", () => {
// verifyRenamingFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.DynamicPolling);
// });
it("uses non recursive dynamic polling when renaming file in subfolder", () => {
verifyRenamingFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.DynamicPolling);
});
});
});
}
6 changes: 3 additions & 3 deletions src/harness/virtualFileSystemWithWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ interface Array<T> {}`
}

interface Folder extends FSEntry {
entries: FSEntry[];
entries: SortedArray<FSEntry>;
}

interface SymLink extends FSEntry {
Expand Down Expand Up @@ -504,7 +504,7 @@ interface Array<T> {}`
}

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

Expand Down Expand Up @@ -606,7 +606,7 @@ interface Array<T> {}`

private toFolder(path: string): Folder {
const folder = this.toFsEntry(path) as Folder;
folder.entries = [];
folder.entries = [] as SortedArray<FSEntry>;
return folder;
}

Expand Down