@@ -1362,20 +1362,36 @@ namespace ts.server {
13621362 }
13631363 else {
13641364 if ( this . exceedTotalNonTsFileSizeLimit ( projectOptions . files ) ) {
1365+ project . setProjectOptions ( projectOptions ) ;
1366+ if ( project . languageServiceDiabled ) {
1367+ return ;
1368+ }
1369+
13651370 project . disableLanguageService ( ) ;
13661371 project . directoryWatcher . close ( ) ;
1367- project . directoryWatcher = undefined ;
1368- project . setProjectOptions ( projectOptions ) ;
13691372 return ;
13701373 }
13711374
1372- project . enableLanguageService ( ) ;
1373- if ( ! project . directoryWatcher ) {
1375+ if ( project . languageServiceDiabled ) {
1376+ project . setProjectOptions ( projectOptions ) ;
1377+ project . enableLanguageService ( ) ;
13741378 project . directoryWatcher = this . host . watchDirectory (
13751379 ts . getDirectoryPath ( project . projectFilename ) ,
13761380 path => this . directoryWatchedForSourceFilesChanged ( project , path ) ,
13771381 /*recursive*/ true
13781382 ) ;
1383+
1384+ for ( const rootFilename of projectOptions . files ) {
1385+ if ( this . host . fileExists ( rootFilename ) ) {
1386+ const info = this . openFile ( rootFilename , /*openedByClient*/ false ) ;
1387+ project . addRoot ( info ) ;
1388+ }
1389+ else {
1390+ return { errorMsg : "specified file " + rootFilename + " not found" } ;
1391+ }
1392+ }
1393+ project . finishGraph ( ) ;
1394+ return ;
13791395 }
13801396
13811397 // if the project is too large, the root files might not have been all loaded if the total
@@ -1396,6 +1412,9 @@ namespace ts.server {
13961412 for ( const fileName of fileNamesToAdd ) {
13971413 let info = this . getScriptInfo ( fileName ) ;
13981414 if ( ! info ) {
1415+ if ( ! this . host . fileExists ( info . fileName ) ) {
1416+ return { errorMsg : "specified file " + info . fileName + " not found" } ;
1417+ }
13991418 info = this . openFile ( fileName , /*openedByClient*/ false ) ;
14001419 }
14011420 else {
0 commit comments