@@ -588,11 +588,16 @@ namespace ts.server {
588
588
return this . findExternalProjectByProjectName ( projectName ) || this . findConfiguredProjectByProjectName ( toNormalizedPath ( projectName ) ) ;
589
589
}
590
590
591
- getDefaultProjectForFile ( fileName : NormalizedPath , refreshInferredProjects : boolean ) {
592
- if ( refreshInferredProjects ) {
591
+ getDefaultProjectForFile ( fileName : NormalizedPath , ensureProject : boolean ) {
592
+ let scriptInfo = this . getScriptInfoForNormalizedPath ( fileName ) ;
593
+ if ( ensureProject && ! scriptInfo || scriptInfo . isOrphan ( ) ) {
593
594
this . ensureProjectStructuresUptoDate ( ) ;
595
+ scriptInfo = this . getScriptInfoForNormalizedPath ( fileName ) ;
596
+ if ( ! scriptInfo ) {
597
+ return Errors . ThrowNoProject ( ) ;
598
+ }
599
+ return scriptInfo . getDefaultProject ( ) ;
594
600
}
595
- const scriptInfo = this . getScriptInfoForNormalizedPath ( fileName ) ;
596
601
return scriptInfo && ! scriptInfo . isOrphan ( ) && scriptInfo . getDefaultProject ( ) ;
597
602
}
598
603
@@ -1943,12 +1948,7 @@ namespace ts.server {
1943
1948
for ( const file of changedFiles ) {
1944
1949
const scriptInfo = this . getScriptInfo ( file . fileName ) ;
1945
1950
Debug . assert ( ! ! scriptInfo ) ;
1946
- // apply changes in reverse order
1947
- for ( let i = file . changes . length - 1 ; i >= 0 ; i -- ) {
1948
- const change = file . changes [ i ] ;
1949
- scriptInfo . editContent ( change . span . start , change . span . start + change . span . length , change . newText ) ;
1950
- }
1951
- this . addChangedFile ( scriptInfo ) ;
1951
+ this . applyChangesToFile ( scriptInfo , file . changes ) ;
1952
1952
}
1953
1953
}
1954
1954
@@ -1965,7 +1965,12 @@ namespace ts.server {
1965
1965
}
1966
1966
1967
1967
/* @internal */
1968
- addChangedFile ( scriptInfo : ScriptInfo ) {
1968
+ applyChangesToFile ( scriptInfo : ScriptInfo , changes : TextChange [ ] ) {
1969
+ // apply changes in reverse order
1970
+ for ( let i = changes . length - 1 ; i >= 0 ; i -- ) {
1971
+ const change = changes [ i ] ;
1972
+ scriptInfo . editContent ( change . span . start , change . span . start + change . span . length , change . newText ) ;
1973
+ }
1969
1974
if ( ! this . changedFiles ) {
1970
1975
this . changedFiles = [ scriptInfo ] ;
1971
1976
}
0 commit comments