diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 5129f5e9efe..5420caabe7c 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -360,7 +360,7 @@ namespace ts { let newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName); let canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName); - if (!arrayIsEqualTo(newFileNames, canonicalRootFileNames, /*comparer*/ undefined, /*sortBeforeComparison*/ true)) { + if (!arrayIsEqualTo(newFileNames.sort(), canonicalRootFileNames.sort())) { setCachedProgram(undefined); startTimerForRecompilation(); } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 37109d1aa73..2a16c2c71fb 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -82,7 +82,7 @@ namespace ts { return node.end - node.pos; } - export function arrayIsEqualTo(arr1: T[], arr2: T[], comparer?: (a: T, b: T) => boolean, sortBeforeComparison = false): boolean { + export function arrayIsEqualTo(arr1: T[], arr2: T[], comparer?: (a: T, b: T) => boolean): boolean { if (!arr1 || !arr2) { return arr1 === arr2; } @@ -91,11 +91,6 @@ namespace ts { return false; } - if (sortBeforeComparison) { - arr1.sort(); - arr2.sort(); - } - for (let i = 0; i < arr1.length; ++i) { let equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; if (!equals) { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index bd334279798..b98129f99e9 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -576,7 +576,7 @@ namespace ts.server { let newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f))); let currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f))); - if (!arrayIsEqualTo(currentRootFiles, newRootFiles, /*comparer*/ undefined, /*sortBeforeComparison*/ true)) { + if (!arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { // For configured projects, the change is made outside the tsconfig file, and // it is not likely to affect the project for other files opened by the client. We can // just update the current project.