Commit daeb0b4f authored by Robert Griesemer's avatar Robert Griesemer

go/printer: revert "make empty lines break table alignment"

This reverts commit c116265e.

The change, while addressing issue #26352, introduced another
regression (#26930), which is worse. Reverting this change in
favor of a better fix for the original issue.

Updates #26352.
Fixes #26930.

Change-Id: I71ad12a8212992cce5c1e73907d1f7460f98d9e8
Reviewed-on: https://go-review.googlesource.com/129255
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 81555cb4
...@@ -221,22 +221,13 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp ...@@ -221,22 +221,13 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp
// If the previous line and the current line had single- // If the previous line and the current line had single-
// line-expressions and the key sizes are small or the // line-expressions and the key sizes are small or the
// ratio between the current key and the geometric mean // ratio between the current key and the geometric mean
// does not exceed a threshold, align columns and do not use // if the previous key sizes does not exceed a threshold,
// formfeed. // align columns and do not use formfeed.
// If the previous line was an empty line, break the alignment.
// (The text/tabwriter will break alignment after an empty line
// even if we don't do anything here, but we can't see that; yet
// we need to reset the variables used in the geomean
// computation after an alignment break. Do it explicitly
// instead so we're aware of the break. Was issue #26352.)
if prevSize > 0 && size > 0 { if prevSize > 0 && size > 0 {
const smallSize = 40 const smallSize = 40
switch { if count == 0 || prevSize <= smallSize && size <= smallSize {
case prevLine+1 < line:
useFF = true
case count == 0, prevSize <= smallSize && size <= smallSize:
useFF = false useFF = false
default: } else {
const r = 2.5 // threshold const r = 2.5 // threshold
geomean := math.Exp(lnsum / float64(count)) // count > 0 geomean := math.Exp(lnsum / float64(count)) // count > 0
ratio := float64(size) / geomean ratio := float64(size) / geomean
......
...@@ -128,12 +128,3 @@ func main() { ...@@ -128,12 +128,3 @@ func main() {
abcdefghijklmnopqrstuvwxyz: "foo", abcdefghijklmnopqrstuvwxyz: "foo",
} }
} }
// ----------------------------------------------------------------------------
// Examples from issue #26352.
var _ = map[int]string{
1: "",
12345678901234567890123456789: "",
12345678901234567890123456789012345678: "",
}
...@@ -128,12 +128,3 @@ func main() { ...@@ -128,12 +128,3 @@ func main() {
abcdefghijklmnopqrstuvwxyz: "foo", abcdefghijklmnopqrstuvwxyz: "foo",
} }
} }
// ----------------------------------------------------------------------------
// Examples from issue #26352.
var _ = map[int]string{
1: "",
12345678901234567890123456789: "",
12345678901234567890123456789012345678: "",
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment