@@ -9183,8 +9183,21 @@ export function Test2() {
91839183 content : 'import { fnA, instanceA } from "../a/bin/a";\nimport { fnB } from "../b/bin/b";\nexport function fnUser() { fnA(); fnB(); instanceA; }' ,
91849184 } ;
91859185
9186- function makeSampleProjects ( ) {
9187- const host = createServerHost ( [ aTs , aTsconfig , aDtsMap , aDts , bTsconfig , bTs , bDtsMap , bDts , userTs , dummyFile ] ) ;
9186+ const userTsForConfigProject : File = {
9187+ path : "/user/user.ts" ,
9188+ content : 'import { fnA, instanceA } from "../a/a";\nimport { fnB } from "../b/b";\nexport function fnUser() { fnA(); fnB(); instanceA; }' ,
9189+ } ;
9190+
9191+ const userTsconfig : File = {
9192+ path : "/user/tsconfig.json" ,
9193+ content : JSON . stringify ( {
9194+ file : [ "user.ts" ] ,
9195+ references : [ { path : "../a" } , { path : "../b" } ]
9196+ } )
9197+ } ;
9198+
9199+ function makeSampleProjects ( addUserTsConfig ?: boolean ) {
9200+ const host = createServerHost ( [ aTs , aTsconfig , aDtsMap , aDts , bTsconfig , bTs , bDtsMap , bDts , ...( addUserTsConfig ? [ userTsForConfigProject , userTsconfig ] : [ userTs ] ) , dummyFile ] ) ;
91889201 const session = createSession ( host ) ;
91899202
91909203 checkDeclarationFiles ( aTs , session , [ aDtsMap , aDts ] ) ;
@@ -9195,7 +9208,7 @@ export function Test2() {
91959208
91969209 openFilesForSession ( [ userTs ] , session ) ;
91979210 const service = session . getProjectService ( ) ;
9198- checkNumberOfProjects ( service , { inferredProjects : 1 } ) ;
9211+ checkNumberOfProjects ( service , addUserTsConfig ? { configuredProjects : 1 } : { inferredProjects : 1 } ) ;
91999212 return session ;
92009213 }
92019214
@@ -9247,6 +9260,10 @@ export function Test2() {
92479260 verifyATsConfigProject ( session ) ; // ATsConfig should still be alive
92489261 }
92499262
9263+ function verifyUserTsConfigProject ( session : TestSession ) {
9264+ checkProjectActualFiles ( session . getProjectService ( ) . configuredProjects . get ( userTsconfig . path ) ! , [ userTs . path , aDts . path , userTsconfig . path ] ) ;
9265+ }
9266+
92509267 it ( "goToDefinition" , ( ) => {
92519268 const session = makeSampleProjects ( ) ;
92529269 const response = executeSessionRequest < protocol . DefinitionRequest , protocol . DefinitionResponse > ( session , protocol . CommandTypes . Definition , protocolFileLocationFromSubstring ( userTs , "fnA()" ) ) ;
@@ -9264,6 +9281,29 @@ export function Test2() {
92649281 verifySingleInferredProject ( session ) ;
92659282 } ) ;
92669283
9284+ it ( "getDefinitionAndBoundSpan with file navigation" , ( ) => {
9285+ const session = makeSampleProjects ( /*addUserTsConfig*/ true ) ;
9286+ const response = executeSessionRequest < protocol . DefinitionAndBoundSpanRequest , protocol . DefinitionAndBoundSpanResponse > ( session , protocol . CommandTypes . DefinitionAndBoundSpan , protocolFileLocationFromSubstring ( userTs , "fnA()" ) ) ;
9287+ assert . deepEqual ( response , {
9288+ textSpan : protocolTextSpanFromSubstring ( userTs . content , "fnA" , { index : 1 } ) ,
9289+ definitions : [ protocolFileSpanFromSubstring ( aTs , "fnA" ) ] ,
9290+ } ) ;
9291+ checkNumberOfProjects ( session . getProjectService ( ) , { configuredProjects : 1 } ) ; debugger ;
9292+ verifyUserTsConfigProject ( session ) ;
9293+
9294+ // Navigate to the definition
9295+ closeFilesForSession ( [ userTs ] , session ) ;
9296+ openFilesForSession ( [ aTs ] , session ) ;
9297+
9298+ // UserTs configured project should be alive
9299+ checkNumberOfProjects ( session . getProjectService ( ) , { configuredProjects : 2 } ) ;
9300+ verifyUserTsConfigProject ( session ) ;
9301+ verifyATsConfigProject ( session ) ;
9302+
9303+ closeFilesForSession ( [ aTs ] , session ) ;
9304+ verifyOnlyOrphanInferredProject ( session ) ;
9305+ } ) ;
9306+
92679307 it ( "goToType" , ( ) => {
92689308 const session = makeSampleProjects ( ) ;
92699309 const response = executeSessionRequest < protocol . TypeDefinitionRequest , protocol . TypeDefinitionResponse > ( session , protocol . CommandTypes . TypeDefinition , protocolFileLocationFromSubstring ( userTs , "instanceA" ) ) ;
0 commit comments