@@ -1399,6 +1399,32 @@ namespace ts {
13991399 /** Returns lower case string */
14001400 export function toLowerCase ( x : string ) { return x . toLowerCase ( ) ; }
14011401
1402+ const fileNameLowerCaseRegExp = / [ ^ İ i ̇ ı ß a - z 0 - 9 \\ / : \- _ \. ] + / g;
1403+ export function toFileNameLowerCase ( x : string ) {
1404+ // Handle special characters and make those case sensitive instead
1405+ //
1406+ // |-#--|-Character-|-Char code-|-Desc------------------------------------------------------|
1407+ // | 1. | i | 105 | Ascii i |
1408+ // | 2. | I | 73 | Ascii I |
1409+ // |-------- Special characters ------------------------------------------------------------|
1410+ // | 3. | İ | 304 | Uppper case I with dot above |
1411+ // | 4. | i̇ | 105,775 | Lower case of İ (3rd item) |
1412+ // | 5. | İ | 73,775 | Upper case of i̇ (4th item), lower case is i̇ (4th item) |
1413+ // | 6. | ı | 305 | Lower case i without dot, upper case is I (2nd item) |
1414+ // | 7. | ß | 223 | Lower case sharp s
1415+ //
1416+ // Because item 3 is special where in its lowercase character has its own
1417+ // upper case form we cant convert its case.
1418+ // Rest special characters are either already in lower case format or
1419+ // they have corresponding upper case character so they dont need special handling
1420+ //
1421+ // But to avoid having to do string building for most common cases, also ignore
1422+ // a-z, 0-9, i̇, ı, ß, \, /, ., : and space
1423+ return fileNameLowerCaseRegExp . test ( x ) ?
1424+ x . replace ( fileNameLowerCaseRegExp , toLowerCase ) :
1425+ x ;
1426+ }
1427+
14021428 /** Throws an error because a function is not implemented. */
14031429 export function notImplemented ( ) : never {
14041430 throw new Error ( "Not implemented" ) ;
@@ -1860,7 +1886,7 @@ namespace ts {
18601886
18611887 export type GetCanonicalFileName = ( fileName : string ) => string ;
18621888 export function createGetCanonicalFileName ( useCaseSensitiveFileNames : boolean ) : GetCanonicalFileName {
1863- return useCaseSensitiveFileNames ? identity : toLowerCase ;
1889+ return useCaseSensitiveFileNames ? identity : toFileNameLowerCase ;
18641890 }
18651891
18661892 /** Represents a "prefix*suffix" pattern. */
@@ -2006,4 +2032,4 @@ namespace ts {
20062032 }
20072033 }
20082034 }
2009- }
2035+ }
0 commit comments