@@ -787,12 +787,12 @@ namespace ts.server {
787787 * we first detect if there is already a configured project created for it: if so, we re-read
788788 * the tsconfig file content and update the project; otherwise we create a new one.
789789 */
790- private openOrUpdateConfiguredProjectForFile ( fileName : NormalizedPath ) : OpenConfiguredProjectResult {
790+ private openOrUpdateConfiguredProjectForFile ( fileName : NormalizedPath , projectRootPath ?: NormalizedPath ) : OpenConfiguredProjectResult {
791791 const searchPath = getDirectoryPath ( fileName ) ;
792792 this . logger . info ( `Search path: ${ searchPath } ` ) ;
793793
794794 // 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 ) ;
796796 if ( ! configFileName ) {
797797 this . logger . info ( "No config files found." ) ;
798798 return { } ;
@@ -826,8 +826,8 @@ namespace ts.server {
826826 // current directory (the directory in which tsc was invoked).
827827 // The server must start searching from the directory containing
828828 // 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 ) {
831831 const tsconfigFileName = asNormalizedPath ( combinePaths ( searchPath , "tsconfig.json" ) ) ;
832832 if ( this . host . fileExists ( tsconfigFileName ) ) {
833833 return tsconfigFileName ;
@@ -1326,17 +1326,17 @@ namespace ts.server {
13261326 * @param filename is absolute pathname
13271327 * @param fileContent is a known version of the file content that is more up to date than the one on disk
13281328 */
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 ) ;
13311331 }
13321332
1333- openClientFileWithNormalizedPath ( fileName : NormalizedPath , fileContent ?: string , scriptKind ?: ScriptKind , hasMixedContent ?: boolean ) : OpenConfiguredProjectResult {
1333+ openClientFileWithNormalizedPath ( fileName : NormalizedPath , fileContent ?: string , scriptKind ?: ScriptKind , hasMixedContent ?: boolean , projectRootPath ?: NormalizedPath ) : OpenConfiguredProjectResult {
13341334 let configFileName : NormalizedPath ;
13351335 let configFileErrors : Diagnostic [ ] ;
13361336
13371337 let project : ConfiguredProject | ExternalProject = this . findContainingExternalProject ( fileName ) ;
13381338 if ( ! project ) {
1339- ( { configFileName, configFileErrors } = this . openOrUpdateConfiguredProjectForFile ( fileName ) ) ;
1339+ ( { configFileName, configFileErrors } = this . openOrUpdateConfiguredProjectForFile ( fileName , projectRootPath ) ) ;
13401340 if ( configFileName ) {
13411341 project = this . findConfiguredProjectByProjectName ( configFileName ) ;
13421342 }
0 commit comments