Helper for getting string comparer

This commit is contained in:
Sheetal Nandi 2018-04-19 10:51:20 -07:00
parent 4b19d12e0e
commit 13d993b954
2 changed files with 7 additions and 3 deletions

View File

@ -1762,6 +1762,10 @@ namespace ts {
return compareComparableValues(a, b);
}
export function getStringComparer(ignoreCase?: boolean) {
return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
}
/**
* Creates a string comparer for use with string collation in the UI.
*/
@ -2274,7 +2278,7 @@ namespace ts {
const aComponents = getNormalizedPathComponents(a, currentDirectory);
const bComponents = getNormalizedPathComponents(b, currentDirectory);
const sharedLength = Math.min(aComponents.length, bComponents.length);
const comparer = ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
const comparer = getStringComparer(ignoreCase);
for (let i = 0; i < sharedLength; i++) {
const result = comparer(aComponents[i], bComponents[i]);
if (result !== Comparison.EqualTo) {
@ -2615,7 +2619,7 @@ namespace ts {
}
// Sort the offsets array using either the literal or canonical path representations.
includeBasePaths.sort(useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive);
includeBasePaths.sort(getStringComparer(!useCaseSensitiveFileNames));
// Iterate over each include base path and include unique base paths that are not a
// subpath of an existing base path

View File

@ -698,7 +698,7 @@ namespace ts {
createWatchDirectoryUsing(dynamicPollingWatchFile || createDynamicPriorityPollingWatchFile({ getModifiedTime, setTimeout })) :
watchDirectoryUsingFsWatch;
const watchDirectoryRecursively = createRecursiveDirectoryWatcher({
filePathComparer: useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive,
filePathComparer: getStringComparer(!useCaseSensitiveFileNames),
directoryExists,
getAccessibleSortedChildDirectories: path => getAccessibleFileSystemEntries(path).directories,
watchDirectory,