1
0
mirror of https://github.com/golang/go synced 2024-11-22 00:14:42 -07:00

fix for nodeSize computation, used to determine if

a node fits on one line:
- for purposes of measuring the node size in text,
  don't generate html or use a styler that could
  generate html as it will lead to overly large
  sizes

A consequence of this bug is that source code displayed
with godoc may show functions that fit on one line in
the source on multiple lines.

This change causes no difference to the gofmt formatting
of any files in src or misc.

R=rsc
http://go/go-review/1026034
This commit is contained in:
Robert Griesemer 2009-11-09 09:34:55 -08:00
parent aae64f8c81
commit 53f485813e

View File

@ -1090,8 +1090,12 @@ func (p *printer) genDecl(d *ast.GenDecl, context declContext, multiLine *bool)
//
func (p *printer) nodeSize(n ast.Node, maxSize int) (size int) {
size = maxSize+1; // assume n doesn't fit
// nodeSize computation must be indendent of particular
// style so that we always get the same decision; print
// in RawFormat
cfg := Config{Mode: RawFormat};
var buf bytes.Buffer;
if _, err := p.Config.Fprint(&buf, n); err != nil {
if _, err := cfg.Fprint(&buf, n); err != nil {
return;
}
if buf.Len() <= maxSize {