@@ -23,10 +23,6 @@ namespace ts {
23
23
// More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times.
24
24
export const collator : { compare ( a : string , b : string ) : number } = typeof Intl === "object" && typeof Intl . Collator === "function" ? new Intl . Collator ( ) : undefined ;
25
25
26
- // This means "compare in a case insensitive manner but consider accentsor other diacritic marks"
27
- // (e.g. a ≠ b, a ≠ á, a = A)
28
- const accentSensitivity : Intl . CollatorOptions = { usage : "sort" , sensitivity : "accent" } ;
29
-
30
26
/**
31
27
* Use this function instead of calling "String.prototype.localeCompre". This function will preform appropriate check to make sure that
32
28
* "typeof Intl" is correct as there are reported issues #11110 nad #11339.
@@ -1033,13 +1029,14 @@ namespace ts {
1033
1029
return a < b ? Comparison . LessThan : Comparison . GreaterThan ;
1034
1030
}
1035
1031
1036
- export function compareStrings ( a : string , b : string , locales ?: string | string [ ] , options ?: Intl . CollatorOptions ) : Comparison {
1032
+ export function compareStrings ( a : string , b : string , ignoreCase ?: boolean ) : Comparison {
1037
1033
if ( a === b ) return Comparison . EqualTo ;
1038
1034
if ( a === undefined ) return Comparison . LessThan ;
1039
1035
if ( b === undefined ) return Comparison . GreaterThan ;
1040
- if ( options ) {
1036
+ if ( ignoreCase ) {
1041
1037
if ( collator && String . prototype . localeCompare ) {
1042
- const result = a . localeCompare ( b , locales , options ) ;
1038
+ // accent means a ≠ b, a ≠ á, a = A
1039
+ const result = a . localeCompare ( b , /*locales*/ undefined , { usage : "sort" , sensitivity : "accent" } ) ;
1043
1040
return result < 0 ? Comparison . LessThan : result > 0 ? Comparison . GreaterThan : Comparison . EqualTo ;
1044
1041
}
1045
1042
@@ -1052,7 +1049,7 @@ namespace ts {
1052
1049
}
1053
1050
1054
1051
export function compareStringsCaseInsensitive ( a : string , b : string ) {
1055
- return compareStrings ( a , b , /*locales */ undefined , accentSensitivity ) ;
1052
+ return compareStrings ( a , b , /*ignoreCase */ true ) ;
1056
1053
}
1057
1054
1058
1055
function getDiagnosticFileName ( diagnostic : Diagnostic ) : string {
@@ -1422,8 +1419,7 @@ namespace ts {
1422
1419
const bComponents = getNormalizedPathComponents ( b , currentDirectory ) ;
1423
1420
const sharedLength = Math . min ( aComponents . length , bComponents . length ) ;
1424
1421
for ( let i = 0 ; i < sharedLength ; i ++ ) {
1425
- const result = compareStrings ( aComponents [ i ] , bComponents [ i ] ,
1426
- /*locales*/ undefined , /*options*/ ignoreCase ? accentSensitivity : undefined ) ;
1422
+ const result = compareStrings ( aComponents [ i ] , bComponents [ i ] , ignoreCase ) ;
1427
1423
if ( result !== Comparison . EqualTo ) {
1428
1424
return result ;
1429
1425
}
@@ -1445,8 +1441,7 @@ namespace ts {
1445
1441
}
1446
1442
1447
1443
for ( let i = 0 ; i < parentComponents . length ; i ++ ) {
1448
- const result = compareStrings ( parentComponents [ i ] , childComponents [ i ] ,
1449
- /*locales*/ undefined , /*options*/ ignoreCase ? accentSensitivity : undefined ) ;
1444
+ const result = compareStrings ( parentComponents [ i ] , childComponents [ i ] , ignoreCase ) ;
1450
1445
if ( result !== Comparison . EqualTo ) {
1451
1446
return false ;
1452
1447
}
0 commit comments