Skip to content

Commit 13d993b

Browse files
committed
Helper for getting string comparer
1 parent 4b19d12 commit 13d993b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/compiler/core.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,10 @@ namespace ts {
17621762
return compareComparableValues(a, b);
17631763
}
17641764

1765+
export function getStringComparer(ignoreCase?: boolean) {
1766+
return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
1767+
}
1768+
17651769
/**
17661770
* Creates a string comparer for use with string collation in the UI.
17671771
*/
@@ -2274,7 +2278,7 @@ namespace ts {
22742278
const aComponents = getNormalizedPathComponents(a, currentDirectory);
22752279
const bComponents = getNormalizedPathComponents(b, currentDirectory);
22762280
const sharedLength = Math.min(aComponents.length, bComponents.length);
2277-
const comparer = ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
2281+
const comparer = getStringComparer(ignoreCase);
22782282
for (let i = 0; i < sharedLength; i++) {
22792283
const result = comparer(aComponents[i], bComponents[i]);
22802284
if (result !== Comparison.EqualTo) {
@@ -2615,7 +2619,7 @@ namespace ts {
26152619
}
26162620

26172621
// Sort the offsets array using either the literal or canonical path representations.
2618-
includeBasePaths.sort(useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive);
2622+
includeBasePaths.sort(getStringComparer(!useCaseSensitiveFileNames));
26192623

26202624
// Iterate over each include base path and include unique base paths that are not a
26212625
// subpath of an existing base path

src/compiler/sys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ namespace ts {
698698
createWatchDirectoryUsing(dynamicPollingWatchFile || createDynamicPriorityPollingWatchFile({ getModifiedTime, setTimeout })) :
699699
watchDirectoryUsingFsWatch;
700700
const watchDirectoryRecursively = createRecursiveDirectoryWatcher({
701-
filePathComparer: useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive,
701+
filePathComparer: getStringComparer(!useCaseSensitiveFileNames),
702702
directoryExists,
703703
getAccessibleSortedChildDirectories: path => getAccessibleFileSystemEntries(path).directories,
704704
watchDirectory,

0 commit comments

Comments
 (0)