@@ -14,7 +14,7 @@ namespace ts {
1414 const oldToNew = getPathUpdater ( oldFileOrDirPath , newFileOrDirPath , getCanonicalFileName , sourceMapper ) ;
1515 const newToOld = getPathUpdater ( newFileOrDirPath , oldFileOrDirPath , getCanonicalFileName , sourceMapper ) ;
1616 return textChanges . ChangeTracker . with ( { host, formatContext } , changeTracker => {
17- updateTsconfigFiles ( program , changeTracker , oldToNew , newFileOrDirPath , host . getCurrentDirectory ( ) , useCaseSensitiveFileNames ) ;
17+ updateTsconfigFiles ( program , changeTracker , oldToNew , oldFileOrDirPath , newFileOrDirPath , host . getCurrentDirectory ( ) , useCaseSensitiveFileNames ) ;
1818 updateImports ( program , changeTracker , oldToNew , newToOld , host , getCanonicalFileName ) ;
1919 } ) ;
2020 }
@@ -45,7 +45,7 @@ namespace ts {
4545 return combinePathsSafe ( getDirectoryPath ( a1 ) , rel ) ;
4646 }
4747
48- function updateTsconfigFiles ( program : Program , changeTracker : textChanges . ChangeTracker , oldToNew : PathUpdater , newFileOrDirPath : string , currentDirectory : string , useCaseSensitiveFileNames : boolean ) : void {
48+ function updateTsconfigFiles ( program : Program , changeTracker : textChanges . ChangeTracker , oldToNew : PathUpdater , oldFileOrDirPath : string , newFileOrDirPath : string , currentDirectory : string , useCaseSensitiveFileNames : boolean ) : void {
4949 const { configFile } = program . getCompilerOptions ( ) ;
5050 if ( ! configFile ) return ;
5151 const configDir = getDirectoryPath ( configFile . fileName ) ;
@@ -63,7 +63,8 @@ namespace ts {
6363 const includes = mapDefined ( property . initializer . elements , e => isStringLiteral ( e ) ? e . text : undefined ) ;
6464 const matchers = getFileMatcherPatterns ( configDir , /*excludes*/ [ ] , includes , useCaseSensitiveFileNames , currentDirectory ) ;
6565 // If there isn't some include for this, add a new one.
66- if ( ! getRegexFromPattern ( Debug . assertDefined ( matchers . includeFilePattern ) , useCaseSensitiveFileNames ) . test ( newFileOrDirPath ) ) {
66+ if ( getRegexFromPattern ( Debug . assertDefined ( matchers . includeFilePattern ) , useCaseSensitiveFileNames ) . test ( oldFileOrDirPath ) &&
67+ ! getRegexFromPattern ( Debug . assertDefined ( matchers . includeFilePattern ) , useCaseSensitiveFileNames ) . test ( newFileOrDirPath ) ) {
6768 changeTracker . insertNodeAfter ( configFile , last ( property . initializer . elements ) , createStringLiteral ( relativePath ( newFileOrDirPath ) ) ) ;
6869 }
6970 }
0 commit comments