Skip to content

Commit cc94d2b

Browse files
committed
fix: directive format regression
Restores previous directive regexp expectations. Related to mvdan#327 Fixes mvdan#331
1 parent e350b3c commit cc94d2b

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

format/format.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,14 @@ func (f *fumpter) lineEnd(line int) token.Pos {
327327
var rxCommentDirective = regexp.MustCompile(
328328
`^(?:` +
329329
`[a-z-]+:[a-z]+` +
330-
`|export` +
331-
`|extern` +
332-
`|line` +
333-
`|no(?:inspection|lint)` +
334-
`|#nosec` +
335-
`|NOSONAR` +
336-
`|sys(?:nb)?` +
337-
`)\b`)
330+
`|export\b` +
331+
`|extern\b` +
332+
`|line\b` +
333+
`|no(?:inspection|lint)\b` +
334+
`|#nosec\b` +
335+
`|NOSONAR\b` +
336+
`|sys(?:nb)?\b` +
337+
`)`)
338338

339339
func (f *fumpter) applyPre(c *astutil.Cursor) {
340340
f.splitLongLine(c)

testdata/script/comment-spaced.txtar

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ func c_open(name *byte, mode int, perm int) int
5353

5454
//sysnb Getpid() (pid int)
5555

56+
//foo:bar_one
57+
58+
//foo:bar-two
59+
60+
//foo:bar01
61+
62+
//foo:barOne
63+
64+
//foo:barTwo
65+
5666
//foo is foo.
5767
type foo int
5868

@@ -124,6 +134,16 @@ func c_open(name *byte, mode int, perm int) int
124134

125135
//sysnb Getpid() (pid int)
126136

137+
//foo:bar_one
138+
139+
//foo:bar-two
140+
141+
//foo:bar01
142+
143+
//foo:barOne
144+
145+
//foo:barTwo
146+
127147
// foo is foo.
128148
type foo int
129149

0 commit comments

Comments
 (0)