diff options
author | Robert Griesemer <gri@golang.org> | 2009-11-09 09:34:55 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-11-09 09:34:55 -0800 |
commit | 879769f92c757c0d4daf4ea5b6c5e77528530cf4 (patch) | |
tree | 4687ba7e6a3253a449515a0f2ae3e0d1c89af0da /src | |
parent | 74eb25b7fadb9c1387bc87267c1d9dd00d2142dd (diff) | |
download | golang-879769f92c757c0d4daf4ea5b6c5e77528530cf4.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/pkg/go/printer/nodes.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pkg/go/printer/nodes.go b/src/pkg/go/printer/nodes.go index 1f863c24b..f91a34851 100644 --- a/src/pkg/go/printer/nodes.go +++ b/src/pkg/go/printer/nodes.go @@ -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 { |