@@ -9183,8 +9183,21 @@ export function Test2() {
9183
9183
content : 'import { fnA, instanceA } from "../a/bin/a";\nimport { fnB } from "../b/bin/b";\nexport function fnUser() { fnA(); fnB(); instanceA; }' ,
9184
9184
} ;
9185
9185
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 ] ) ;
9188
9201
const session = createSession ( host ) ;
9189
9202
9190
9203
checkDeclarationFiles ( aTs , session , [ aDtsMap , aDts ] ) ;
@@ -9195,7 +9208,7 @@ export function Test2() {
9195
9208
9196
9209
openFilesForSession ( [ userTs ] , session ) ;
9197
9210
const service = session . getProjectService ( ) ;
9198
- checkNumberOfProjects ( service , { inferredProjects : 1 } ) ;
9211
+ checkNumberOfProjects ( service , addUserTsConfig ? { configuredProjects : 1 } : { inferredProjects : 1 } ) ;
9199
9212
return session ;
9200
9213
}
9201
9214
@@ -9247,6 +9260,10 @@ export function Test2() {
9247
9260
verifyATsConfigProject ( session ) ; // ATsConfig should still be alive
9248
9261
}
9249
9262
9263
+ function verifyUserTsConfigProject ( session : TestSession ) {
9264
+ checkProjectActualFiles ( session . getProjectService ( ) . configuredProjects . get ( userTsconfig . path ) ! , [ userTs . path , aDts . path , userTsconfig . path ] ) ;
9265
+ }
9266
+
9250
9267
it ( "goToDefinition" , ( ) => {
9251
9268
const session = makeSampleProjects ( ) ;
9252
9269
const response = executeSessionRequest < protocol . DefinitionRequest , protocol . DefinitionResponse > ( session , protocol . CommandTypes . Definition , protocolFileLocationFromSubstring ( userTs , "fnA()" ) ) ;
@@ -9264,6 +9281,29 @@ export function Test2() {
9264
9281
verifySingleInferredProject ( session ) ;
9265
9282
} ) ;
9266
9283
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
+
9267
9307
it ( "goToType" , ( ) => {
9268
9308
const session = makeSampleProjects ( ) ;
9269
9309
const response = executeSessionRequest < protocol . TypeDefinitionRequest , protocol . TypeDefinitionResponse > ( session , protocol . CommandTypes . TypeDefinition , protocolFileLocationFromSubstring ( userTs , "instanceA" ) ) ;
0 commit comments