Skip to content

Commit 54033a5

Browse files
authored
Add CLI and LSP attach to launch.template (#3527)
1 parent 30deb0c commit 54033a5

3 files changed

Lines changed: 24 additions & 44 deletions

File tree

.vscode/launch.template.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,29 @@
6161
"-testDir",
6262
"path_to_project_dir"
6363
]
64+
},
65+
{
66+
"name": "Launch tsgo CLI",
67+
"type": "go",
68+
"request": "launch",
69+
"mode": "debug",
70+
"program": "${workspaceFolder}/cmd/tsgo",
71+
"cwd": "${workspaceFolder}",
72+
"args": "${input:tsgoArgs}"
73+
},
74+
{
75+
"name": "Attach to Go process",
76+
"type": "go",
77+
"request": "attach",
78+
"mode": "local",
79+
"processId": "${command:pickGoProcess}"
80+
}
81+
],
82+
"inputs": [
83+
{
84+
"id": "tsgoArgs",
85+
"type": "promptString",
86+
"description": "Enter arguments for tsgo"
6487
}
6588
]
6689
}

internal/project/projectcollectionbuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (b *ProjectCollectionBuilder) DidChangeFiles(summary FileChangeSummary, log
213213
b.markFilesChanged(entry, changedFiles, lsproto.FileChangeTypeChanged, logger)
214214
if entry.Value().Kind == KindInferred && summary.Closed.Len() > 0 {
215215
rootFilesMap := entry.Value().CommandLine.FileNamesByPath()
216-
newRootFiles := slices.Clone(entry.Value().CommandLine.FileNames())
216+
newRootFiles := entry.Value().CommandLine.FileNames()
217217
for uri := range summary.Closed.Keys() {
218218
fileName := uri.FileName()
219219
path := b.toPath(fileName)

internal/project/projectcollectionbuilder_test.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -454,49 +454,6 @@ func TestProjectCollectionBuilder(t *testing.T) {
454454
})
455455
})
456456

457-
t.Run("closing file from inferred project does not corrupt old snapshot", func(t *testing.T) {
458-
t.Parallel()
459-
files := map[string]any{
460-
"/project/a.ts": `export const a = 1;`,
461-
"/project/b.ts": `export const b = 1;`,
462-
}
463-
464-
session, _ := projecttestutil.Setup(files)
465-
466-
// Open two files with no tsconfig → inferred project
467-
session.DidOpenFile(context.Background(), "file:///project/a.ts", 1, files["/project/a.ts"].(string), lsproto.LanguageKindTypeScript)
468-
session.DidOpenFile(context.Background(), "file:///project/b.ts", 1, files["/project/b.ts"].(string), lsproto.LanguageKindTypeScript)
469-
470-
// Force snapshot creation via GetLanguageService
471-
_, err := session.GetLanguageService(context.Background(), "file:///project/a.ts")
472-
assert.NilError(t, err)
473-
474-
oldSnapshot := session.Snapshot()
475-
oldInferred := oldSnapshot.ProjectCollection.InferredProject()
476-
assert.Assert(t, oldInferred != nil)
477-
oldFileNames := oldInferred.CommandLine.FileNames()
478-
assert.DeepEqual(t, oldFileNames, []string{
479-
"/project/a.ts",
480-
"/project/b.ts",
481-
})
482-
483-
// Close one file and trigger a new snapshot
484-
session.DidCloseFile(context.Background(), "file:///project/b.ts")
485-
_, err = session.GetLanguageService(context.Background(), "file:///project/a.ts")
486-
assert.NilError(t, err)
487-
488-
newSnapshot := session.Snapshot()
489-
assert.Assert(t, newSnapshot != oldSnapshot, "snapshot should have changed")
490-
491-
// The old snapshot's inferred project FileNames must not have been mutated
492-
// by processing the close. slices.Delete in DidChangeFiles currently corrupts
493-
// the shared underlying array.
494-
assert.DeepEqual(t, oldFileNames, []string{
495-
"/project/a.ts",
496-
"/project/b.ts",
497-
})
498-
})
499-
500457
t.Run("project lookup terminates", func(t *testing.T) {
501458
t.Parallel()
502459
files := map[string]any{

0 commit comments

Comments
 (0)