@@ -130,3 +130,48 @@ func TestProjectProgramUpdateKind(t *testing.T) {
130130 assert .Equal (t , configured .ProgramUpdateKind , project .ProgramUpdateKindSameFileNames )
131131 })
132132}
133+
134+ func TestProject (t * testing.T ) {
135+ t .Parallel ()
136+ if ! bundled .Embedded {
137+ t .Skip ("bundled files are not embedded" )
138+ }
139+
140+ t .Run ("commandLineWithTypingsFiles is reset on CommandLine change" , func (t * testing.T ) {
141+ t .Parallel ()
142+ files := map [string ]any {
143+ "/user/username/projects/project1/app.js" : `` ,
144+ "/user/username/projects/project1/package.json" : `{"name":"p1","dependencies":{"jquery":"^3.1.0"}}` ,
145+ "/user/username/projects/project2/app.js" : `` ,
146+ }
147+
148+ session , utils := projecttestutil .SetupWithTypingsInstaller (files , & projecttestutil.TypingsInstallerOptions {
149+ PackageToFile : map [string ]string {
150+ // Provide typings content to be installed for jquery so ATA actually installs something
151+ "jquery" : `declare const $: { x: number }` ,
152+ },
153+ })
154+
155+ // 1) Open an inferred project file that triggers ATA
156+ uri1 := lsproto .DocumentUri ("file:///user/username/projects/project1/app.js" )
157+ session .DidOpenFile (context .Background (), uri1 , 1 , files ["/user/username/projects/project1/app.js" ].(string ), lsproto .LanguageKindJavaScript )
158+
159+ // 2) Wait for ATA/background tasks to finish, then get a language service for the first file
160+ session .WaitForBackgroundTasks ()
161+ // Sanity check: ensure ATA performed at least one install
162+ npmCalls := utils .NpmExecutor ().NpmInstallCalls ()
163+ assert .Assert (t , len (npmCalls ) > 0 , "expected at least one npm install call from ATA" )
164+ _ , err := session .GetLanguageService (context .Background (), uri1 )
165+ assert .NilError (t , err )
166+
167+ // 3) Open another inferred project file
168+ uri2 := lsproto .DocumentUri ("file:///user/username/projects/project2/app.js" )
169+ session .DidOpenFile (context .Background (), uri2 , 1 , `` , lsproto .LanguageKindJavaScript )
170+
171+ // 4) Get a language service for the second file
172+ // If commandLineWithTypingsFiles was not reset, the new program command line
173+ // won't include the newly opened file and this will fail.
174+ _ , err = session .GetLanguageService (context .Background (), uri2 )
175+ assert .NilError (t , err )
176+ })
177+ }
0 commit comments