@@ -321,16 +321,16 @@ namespace ts {
321321 return getSourceTextOfNodeFromSourceFile ( getSourceFileOfNode ( node ) , node , includeTrivia ) ;
322322 }
323323
324+ function getPos ( range : Node ) {
325+ return range . pos ;
326+ }
327+
324328 /**
325329 * Note: it is expected that the `nodeArray` and the `node` are within the same file.
326330 * For example, searching for a `SourceFile` in a `SourceFile[]` wouldn't work.
327331 */
328332 export function indexOfNode ( nodeArray : ReadonlyArray < Node > , node : Node ) {
329- return binarySearch ( nodeArray , node , compareNodePos ) ;
330- }
331-
332- function compareNodePos ( { pos : aPos } : Node , { pos : bPos } : Node ) {
333- return aPos < bPos ? Comparison . LessThan : bPos < aPos ? Comparison . GreaterThan : Comparison . EqualTo ;
333+ return binarySearch ( nodeArray , node , getPos , compareValues ) ;
334334 }
335335
336336 /**
@@ -2292,6 +2292,7 @@ namespace ts {
22922292 let nonFileDiagnostics : Diagnostic [ ] = [ ] ;
22932293 const fileDiagnostics = createMap < Diagnostic [ ] > ( ) ;
22942294
2295+ let hasReadNonFileDiagnostics = false ;
22952296 let diagnosticsModified = false ;
22962297 let modificationCount = 0 ;
22972298
@@ -2321,6 +2322,12 @@ namespace ts {
23212322 }
23222323 }
23232324 else {
2325+ // If we've already read the non-file diagnostics, do not modify the existing array.
2326+ if ( hasReadNonFileDiagnostics ) {
2327+ hasReadNonFileDiagnostics = false ;
2328+ nonFileDiagnostics = nonFileDiagnostics . slice ( ) ;
2329+ }
2330+
23242331 diagnostics = nonFileDiagnostics ;
23252332 }
23262333
@@ -2331,6 +2338,7 @@ namespace ts {
23312338
23322339 function getGlobalDiagnostics ( ) : Diagnostic [ ] {
23332340 sortAndDeduplicate ( ) ;
2341+ hasReadNonFileDiagnostics = true ;
23342342 return nonFileDiagnostics ;
23352343 }
23362344
@@ -3950,6 +3958,9 @@ namespace ts {
39503958 trySetLanguageAndTerritory ( language , /*territory*/ undefined , errors ) ;
39513959 }
39523960
3961+ // Set the UI locale for string collation
3962+ setUILocale ( locale ) ;
3963+
39533964 function trySetLanguageAndTerritory ( language : string , territory : string , errors ?: Push < Diagnostic > ) : boolean {
39543965 const compilerFilePath = normalizePath ( sys . getExecutingFilePath ( ) ) ;
39553966 const containingDirectoryPath = getDirectoryPath ( compilerFilePath ) ;
0 commit comments