File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -277,11 +277,10 @@ module ts {
277277 // specified since the last compilation cycle.
278278 removeWatchers ( program ) ;
279279
280- // Gets us syntactically correct files from the last compilation.
281- var oldSourceFiles = arrayToMap ( program . getSourceFiles ( ) , file => getCanonicalName ( file . filename ) ) ;
282-
283- // No longer using the old program.
284- program = undefined ;
280+ // Reuse source files from the last compilation so long as they weren't changed.
281+ var oldSourceFiles = arrayToMap (
282+ filter ( program . getSourceFiles ( ) , file => ! hasProperty ( changedFiles , getCanonicalName ( file . filename ) ) ) ,
283+ file => getCanonicalName ( file . filename ) ) ;
285284
286285 // We create a new compiler host for this compilation cycle.
287286 // This new host is effectively the same except that 'getSourceFile'
@@ -291,11 +290,9 @@ module ts {
291290 newCompilerHost . getSourceFile = ( fileName , languageVersion , onError ) => {
292291 fileName = getCanonicalName ( fileName ) ;
293292
294- if ( ! hasProperty ( changedFiles , fileName ) ) {
295- var sourceFile = lookUp ( oldSourceFiles , fileName ) ;
296- if ( sourceFile ) {
297- return sourceFile ;
298- }
293+ var sourceFile = lookUp ( oldSourceFiles , fileName ) ;
294+ if ( sourceFile ) {
295+ return sourceFile ;
299296 }
300297
301298 return compilerHost . getSourceFile ( fileName , languageVersion , onError ) ;
You can’t perform that action at this time.
0 commit comments