File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ func CommentToMarkdown(text string) string {
32
32
var p comment.Parser
33
33
doc := p .Parse (text )
34
34
var pr comment.Printer
35
+ // The default produces {#Hdr-...} tags for headings.
36
+ // vscode displays thems, which is undesirable.
37
+ // The godoc for comment.Printer says the tags
38
+ // avoid a security problem.
39
+ pr .HeadingID = func (* comment.Heading ) string { return "" }
35
40
easy := pr .Markdown (doc )
36
41
return string (easy )
37
42
}
Original file line number Diff line number Diff line change @@ -221,3 +221,42 @@ func main() {
221
221
}
222
222
})
223
223
}
224
+
225
+ // for x/tools/gopls: unhandled named anchor on the hover #57048
226
+ func TestHoverTags (t * testing.T ) {
227
+ testenv .NeedsGo1Point (t , 14 ) // until go1.13 is dropped from kokoro
228
+ const source = `
229
+ -- go.mod --
230
+ module mod.com
231
+
232
+ go 1.19
233
+
234
+ -- lib/a.go --
235
+
236
+ // variety of execution modes.
237
+ //
238
+ // # Test package setup
239
+ //
240
+ // The regression test package uses a couple of uncommon patterns to reduce
241
+ package lib
242
+
243
+ -- a.go --
244
+ package main
245
+ import "mod.com/lib"
246
+
247
+ const A = 1
248
+
249
+ }
250
+ `
251
+ Run (t , source , func (t * testing.T , env * Env ) {
252
+ t .Run ("tags" , func (t * testing.T ) {
253
+ env .OpenFile ("a.go" )
254
+ z := env .RegexpSearch ("a.go" , "lib" )
255
+ t .Logf ("%#v" , z )
256
+ got , _ := env .Hover ("a.go" , env .RegexpSearch ("a.go" , "lib" ))
257
+ if strings .Contains (got .Value , "{#hdr-" ) {
258
+ t .Errorf ("Hover: got {#hdr- tag:\n %q" , got )
259
+ }
260
+ })
261
+ })
262
+ }
You can’t perform that action at this time.
0 commit comments