mirror of
https://github.com/golang/go
synced 2024-11-17 08:14:48 -07:00
cmd/doc: adding validation before adding comment marker
Previous fix in issue #20929 for adding comment marker does not check whether string field have // prefix or not. This commit ensures string field does not contain // before adding prefix to the line. Test also included in this commit. Fixes #40992 Change-Id: Ibc5e8ef147eeb2ed732fb9e19815c8b21fcfb2ab Reviewed-on: https://go-review.googlesource.com/c/go/+/251237 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Robert Griesemer <gri@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
parent
45205bc47b
commit
cc0930cd1d
@ -487,7 +487,7 @@ func (l *lineWrapper) write(text string) {
|
||||
l.out.Write(nl)
|
||||
l.n = 0
|
||||
l.pendSpace = 0
|
||||
needsPrefix = isComment
|
||||
needsPrefix = isComment && !strings.HasPrefix(f, "//")
|
||||
}
|
||||
if l.n == 0 {
|
||||
l.out.Write([]byte(l.indent))
|
||||
|
@ -152,6 +152,17 @@ A very long line of 46 char for line wrapping. */`,
|
||||
text: `. /* A very long line of 46 char for line
|
||||
. wrapping. A very long line of 46 char
|
||||
. for line wrapping. */
|
||||
`,
|
||||
},
|
||||
{
|
||||
in: `A line of 36 char for line wrapping.
|
||||
//Another line starting with //`,
|
||||
out: []block{
|
||||
{opPara, []string{"A line of 36 char for line wrapping.\n",
|
||||
"//Another line starting with //"}},
|
||||
},
|
||||
text: `. A line of 36 char for line wrapping.
|
||||
. //Another line starting with //
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user