@@ -787,12 +787,12 @@ namespace ts.server {
787
787
* we first detect if there is already a configured project created for it: if so, we re-read
788
788
* the tsconfig file content and update the project; otherwise we create a new one.
789
789
*/
790
- private openOrUpdateConfiguredProjectForFile ( fileName : NormalizedPath ) : OpenConfiguredProjectResult {
790
+ private openOrUpdateConfiguredProjectForFile ( fileName : NormalizedPath , projectRootPath ?: NormalizedPath ) : OpenConfiguredProjectResult {
791
791
const searchPath = getDirectoryPath ( fileName ) ;
792
792
this . logger . info ( `Search path: ${ searchPath } ` ) ;
793
793
794
794
// check if this file is already included in one of external projects
795
- const configFileName = this . findConfigFile ( asNormalizedPath ( searchPath ) ) ;
795
+ const configFileName = this . findConfigFile ( asNormalizedPath ( searchPath ) , projectRootPath ) ;
796
796
if ( ! configFileName ) {
797
797
this . logger . info ( "No config files found." ) ;
798
798
return { } ;
@@ -826,8 +826,8 @@ namespace ts.server {
826
826
// current directory (the directory in which tsc was invoked).
827
827
// The server must start searching from the directory containing
828
828
// the newly opened file.
829
- private findConfigFile ( searchPath : NormalizedPath ) : NormalizedPath {
830
- while ( true ) {
829
+ private findConfigFile ( searchPath : NormalizedPath , projectRootPath ?: NormalizedPath ) : NormalizedPath {
830
+ while ( ! projectRootPath || searchPath . indexOf ( projectRootPath ) >= 0 ) {
831
831
const tsconfigFileName = asNormalizedPath ( combinePaths ( searchPath , "tsconfig.json" ) ) ;
832
832
if ( this . host . fileExists ( tsconfigFileName ) ) {
833
833
return tsconfigFileName ;
@@ -1326,17 +1326,17 @@ namespace ts.server {
1326
1326
* @param filename is absolute pathname
1327
1327
* @param fileContent is a known version of the file content that is more up to date than the one on disk
1328
1328
*/
1329
- openClientFile ( fileName : string , fileContent ?: string , scriptKind ?: ScriptKind ) : OpenConfiguredProjectResult {
1330
- return this . openClientFileWithNormalizedPath ( toNormalizedPath ( fileName ) , fileContent , scriptKind ) ;
1329
+ openClientFile ( fileName : string , fileContent ?: string , scriptKind ?: ScriptKind , projectRootPath ?: string ) : OpenConfiguredProjectResult {
1330
+ return this . openClientFileWithNormalizedPath ( toNormalizedPath ( fileName ) , fileContent , scriptKind , /*hasMixedContent*/ false , projectRootPath ? toNormalizedPath ( projectRootPath ) : undefined ) ;
1331
1331
}
1332
1332
1333
- openClientFileWithNormalizedPath ( fileName : NormalizedPath , fileContent ?: string , scriptKind ?: ScriptKind , hasMixedContent ?: boolean ) : OpenConfiguredProjectResult {
1333
+ openClientFileWithNormalizedPath ( fileName : NormalizedPath , fileContent ?: string , scriptKind ?: ScriptKind , hasMixedContent ?: boolean , projectRootPath ?: NormalizedPath ) : OpenConfiguredProjectResult {
1334
1334
let configFileName : NormalizedPath ;
1335
1335
let configFileErrors : Diagnostic [ ] ;
1336
1336
1337
1337
let project : ConfiguredProject | ExternalProject = this . findContainingExternalProject ( fileName ) ;
1338
1338
if ( ! project ) {
1339
- ( { configFileName, configFileErrors } = this . openOrUpdateConfiguredProjectForFile ( fileName ) ) ;
1339
+ ( { configFileName, configFileErrors } = this . openOrUpdateConfiguredProjectForFile ( fileName , projectRootPath ) ) ;
1340
1340
if ( configFileName ) {
1341
1341
project = this . findConfiguredProjectByProjectName ( configFileName ) ;
1342
1342
}
0 commit comments