Skip to content

Commit 7ddb9a1

Browse files
committed
update:codelens for proj test classfile
1 parent 5af9b34 commit 7ddb9a1

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

gopls/internal/lsp/source/code_lens_gox.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ func goxTestCodeLens(pgf *ParsedGopFile, classType string) ([]protocol.CodeLens,
215215
if err != nil {
216216
return nil, err
217217
}
218+
codelens := []protocol.CodeLens{
219+
{Range: rng, Command: &protocol.Command{
220+
Title: "run test package",
221+
Command: "gop.test.package",
222+
}},
223+
}
224+
if pgf.File.IsProj && classType == "main" { //goxls:proj gox test
225+
return codelens, nil
226+
}
218227
args, err := command.MarshalArgs(
219228
map[string]string{
220229
"functionName": "Test_" + classType,
@@ -223,16 +232,13 @@ func goxTestCodeLens(pgf *ParsedGopFile, classType string) ([]protocol.CodeLens,
223232
if err != nil {
224233
return nil, err
225234
}
226-
codelens := []protocol.CodeLens{
227-
{Range: rng, Command: &protocol.Command{
228-
Title: "run test package",
229-
Command: "gop.test.package",
230-
}},
231-
{Range: rng, Command: &protocol.Command{ // goxls: add test cursor as test file
235+
codelens = append(codelens, protocol.CodeLens{
236+
Range: rng,
237+
Command: &protocol.Command{
232238
Title: "run file tests",
233239
Command: "gop.test.cursor",
234240
Arguments: args,
235-
}},
236-
}
241+
},
242+
})
237243
return codelens, nil
238244
}

0 commit comments

Comments
 (0)