@@ -1454,10 +1454,12 @@ namespace ts.server {
1454
1454
1455
1455
const excludeRules : string [ ] = [ ] ;
1456
1456
1457
+ const normalizedNames = rootFiles . map ( f => normalizeSlashes ( f . fileName ) ) ;
1458
+
1457
1459
for ( const name of Object . keys ( ProjectService . safelist ) ) {
1458
1460
const rule = ProjectService . safelist [ name ] ;
1459
- for ( const root of rootFiles ) {
1460
- if ( rule . match . test ( root . fileName ) ) {
1461
+ for ( const root of normalizedNames ) {
1462
+ if ( rule . match . test ( root ) ) {
1461
1463
this . logger . info ( `Excluding files based on rule ${ name } ` ) ;
1462
1464
1463
1465
// If the file matches, collect its types packages and exclude rules
@@ -1471,7 +1473,7 @@ namespace ts.server {
1471
1473
1472
1474
if ( rule . exclude ) {
1473
1475
for ( const exclude of rule . exclude ) {
1474
- const processedRule = root . fileName . replace ( rule . match , ( ...groups : Array < string > ) => {
1476
+ const processedRule = root . replace ( rule . match , ( ...groups : Array < string > ) => {
1475
1477
return exclude . map ( groupNumberOrString => {
1476
1478
// RegExp group numbers are 1-based, but the first element in groups
1477
1479
// is actually the original string, so it all works out in the end.
@@ -1488,15 +1490,16 @@ namespace ts.server {
1488
1490
} ) . join ( "" ) ;
1489
1491
} ) ;
1490
1492
1491
- if ( excludeRules . indexOf ( processedRule ) == - 1 ) {
1493
+ if ( excludeRules . indexOf ( processedRule ) === - 1 ) {
1492
1494
excludeRules . push ( processedRule ) ;
1493
1495
}
1494
1496
}
1495
1497
}
1496
1498
else {
1497
1499
// If not rules listed, add the default rule to exclude the matched file
1498
- if ( excludeRules . indexOf ( root . fileName ) < 0 ) {
1499
- excludeRules . push ( root . fileName ) ;
1500
+ const escaped = ProjectService . escapeFilenameForRegex ( root ) ;
1501
+ if ( excludeRules . indexOf ( escaped ) < 0 ) {
1502
+ excludeRules . push ( escaped ) ;
1500
1503
}
1501
1504
}
1502
1505
}
@@ -1510,7 +1513,7 @@ namespace ts.server {
1510
1513
}
1511
1514
1512
1515
const excludeRegexes = excludeRules . map ( e => new RegExp ( e , "i" ) ) ;
1513
- proj . rootFiles = proj . rootFiles . filter ( file => ! excludeRegexes . some ( re => re . test ( file . fileName ) ) ) ;
1516
+ proj . rootFiles = proj . rootFiles . filter ( ( _file , index ) => ! excludeRegexes . some ( re => re . test ( normalizedNames [ index ] ) ) ) ;
1514
1517
}
1515
1518
1516
1519
openExternalProject ( proj : protocol . ExternalProject , suppressRefreshOfInferredProjects = false ) : void {
0 commit comments