@@ -844,6 +844,68 @@ namespace ts.projectSystem {
844844 const edits = project . getLanguageService ( ) . getFormattingEditsForDocument ( f1 . path , options ) ;
845845 assert . deepEqual ( edits , [ { span : createTextSpan ( /*start*/ 7 , /*length*/ 3 ) , newText : " " } ] ) ;
846846 } ) ;
847+
848+ it ( "when multiple projects are open, detects correct default project" , ( ) => {
849+ //const projectLocation: `/user/username/projects/myproject`;
850+ const barConfig : File = {
851+ path : `${ projectRoot } /bar/tsconfig.json` ,
852+ content : JSON . stringify ( {
853+ include : [ "index.ts" ] ,
854+ compilerOptions : {
855+ lib : [ "dom" , "es2017" ]
856+ }
857+ } )
858+ } ;
859+ const barIndex : File = {
860+ path : `${ projectRoot } /bar/index.ts` ,
861+ content : `
862+ export function bar() {
863+ console.log("hello world");
864+ }`
865+ } ;
866+ const fooConfig : File = {
867+ path : `${ projectRoot } /foo/tsconfig.json` ,
868+ content : JSON . stringify ( {
869+ include : [ "index.ts" ] ,
870+ compilerOptions : {
871+ lib : [ "es2017" ]
872+ }
873+ } )
874+ } ;
875+ const fooIndex : File = {
876+ path : `${ projectRoot } /foo/index.ts` ,
877+ content : `
878+ import { bar } from "bar";
879+ bar();`
880+ } ;
881+ const barSymLink : SymLink = {
882+ path : `${ projectRoot } /foo/node_modules/bar` ,
883+ symLink : `${ projectRoot } /bar`
884+ } ;
885+
886+ const lib2017 : File = {
887+ path : `${ getDirectoryPath ( libFile . path ) } /lib.es2017.d.ts` ,
888+ content : libFile . content
889+ } ;
890+ const libDom : File = {
891+ path : `${ getDirectoryPath ( libFile . path ) } /lib.dom.d.ts` ,
892+ content : `
893+ declare var console: {
894+ log(...args: any[]): void;
895+ };`
896+ } ;
897+ const host = createServerHost ( [ barConfig , barIndex , fooConfig , fooIndex , barSymLink , lib2017 , libDom ] ) ;
898+ const session = createSession ( host , { canUseEvents : true , } ) ;
899+ openFilesForSession ( [ fooIndex , barIndex ] , session ) ;
900+ verifyGetErrRequest ( {
901+ session,
902+ host,
903+ expected : [
904+ { file : barIndex , syntax : [ ] , semantic : [ ] , suggestion : [ ] } ,
905+ { file : fooIndex , syntax : [ ] , semantic : [ ] , suggestion : [ ] } ,
906+ ]
907+ } ) ;
908+ } ) ;
847909 } ) ;
848910
849911 describe ( "unittests:: tsserver:: ConfiguredProjects:: non-existing directories listed in config file input array" , ( ) => {
0 commit comments