mirror of
https://github.com/golang/go
synced 2024-11-17 12:44:49 -07:00
go/doc/comment: don't crash if there are no words to wrap
Fixes #52783 Change-Id: I12e3da40d49cd92776052bf19cb07ee8a07f3ee0 Reviewed-on: https://go-review.googlesource.com/c/go/+/405215 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
a971499a62
commit
3f43096f15
16
src/go/doc/comment/testdata/crash1.txt
vendored
Normal file
16
src/go/doc/comment/testdata/crash1.txt
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
-- input --
|
||||
[]
|
||||
|
||||
[]: http://
|
||||
-- gofmt --
|
||||
[]
|
||||
|
||||
[]: http://
|
||||
-- html --
|
||||
<p><a href="http://"></a>
|
||||
-- markdown --
|
||||
[](http://)
|
||||
-- text --
|
||||
|
||||
|
||||
[]: http://
|
@ -141,7 +141,7 @@ func (p *textPrinter) text(out *bytes.Buffer, indent string, x []Text) {
|
||||
p.long.Reset()
|
||||
|
||||
var seq []int
|
||||
if p.width < 0 {
|
||||
if p.width < 0 || len(words) == 0 {
|
||||
seq = []int{0, len(words)} // one long line
|
||||
} else {
|
||||
seq = wrap(words, p.width-utf8.RuneCountInString(indent))
|
||||
|
Loading…
Reference in New Issue
Block a user