@@ -71,27 +71,29 @@ func runTestCodeLens(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]p
71
71
})
72
72
}
73
73
74
- _ , pgf , err := GetParsedFile (ctx , snapshot , fh , WidestPackage )
75
- if err != nil {
76
- return nil , err
77
- }
78
- // add a code lens to the top of the file which runs all benchmarks in the file
79
- rng , err := NewMappedRange (snapshot .FileSet (), pgf .Mapper , pgf .File .Package , pgf .File .Package ).Range ()
80
- if err != nil {
81
- return nil , err
82
- }
83
- args , err := MarshalArgs (fh .URI (), []string {}, fns .Benchmarks )
84
- if err != nil {
85
- return nil , err
74
+ if len (fns .Benchmarks ) > 0 {
75
+ _ , pgf , err := GetParsedFile (ctx , snapshot , fh , WidestPackage )
76
+ if err != nil {
77
+ return nil , err
78
+ }
79
+ // add a code lens to the top of the file which runs all benchmarks in the file
80
+ rng , err := NewMappedRange (snapshot .FileSet (), pgf .Mapper , pgf .File .Package , pgf .File .Package ).Range ()
81
+ if err != nil {
82
+ return nil , err
83
+ }
84
+ args , err := MarshalArgs (fh .URI (), []string {}, fns .Benchmarks )
85
+ if err != nil {
86
+ return nil , err
87
+ }
88
+ codeLens = append (codeLens , protocol.CodeLens {
89
+ Range : rng ,
90
+ Command : protocol.Command {
91
+ Title : "run file benchmarks" ,
92
+ Command : CommandTest .ID (),
93
+ Arguments : args ,
94
+ },
95
+ })
86
96
}
87
- codeLens = append (codeLens , protocol.CodeLens {
88
- Range : rng ,
89
- Command : protocol.Command {
90
- Title : "run file benchmarks" ,
91
- Command : CommandTest .ID (),
92
- Arguments : args ,
93
- },
94
- })
95
97
return codeLens , nil
96
98
}
97
99
0 commit comments