]> Cypherpunks repositories - gostls13.git/commitdiff
go/printer: revert "make empty lines break table alignment"
authorRobert Griesemer <gri@golang.org>
Tue, 14 Aug 2018 00:25:49 +0000 (17:25 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 14 Aug 2018 15:57:25 +0000 (15:57 +0000)
This reverts commit c116265eb3f2b1a8549e7ceef73b780439404030.

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: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/go/printer/nodes.go
src/go/printer/testdata/alignment.golden
src/go/printer/testdata/alignment.input

index 3723f30e56cf410f23246342878103c8ec0a37fd..18f2371d24b545b0f582ac2548fb5d9fc3aa5481 100644 (file)
@@ -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-
                // line-expressions and the key sizes are small or the
                // ratio between the current key and the geometric mean
-               // does not exceed a threshold, 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 the previous key sizes does not exceed a threshold,
+               // align columns and do not use formfeed.
                if prevSize > 0 && size > 0 {
                        const smallSize = 40
-                       switch {
-                       case prevLine+1 < line:
-                               useFF = true
-                       case count == 0, prevSize <= smallSize && size <= smallSize:
+                       if count == 0 || prevSize <= smallSize && size <= smallSize {
                                useFF = false
-                       default:
+                       } else {
                                const r = 2.5                               // threshold
                                geomean := math.Exp(lnsum / float64(count)) // count > 0
                                ratio := float64(size) / geomean
index 302b32e7667a7ba9e04a177d65e959777bd2a559..c65defe6aec9e640a3c9607581f967f0d24a4511 100644 (file)
@@ -128,12 +128,3 @@ func main() {
                abcdefghijklmnopqrstuvwxyz:             "foo",
        }
 }
-
-// ----------------------------------------------------------------------------
-// Examples from issue #26352.
-var _ = map[int]string{
-       1:      "",
-
-       12345678901234567890123456789:          "",
-       12345678901234567890123456789012345678: "",
-}
index 83361cc7c168a20d019e312605dbfecd6066ac36..9b0aae6bec1e6b5b8f245da97f63438e6dec0e7a 100644 (file)
@@ -128,12 +128,3 @@ func main() {
                abcdefghijklmnopqrstuvwxyz: "foo",
        }
 }
-
-// ----------------------------------------------------------------------------
-// Examples from issue #26352.
-var _ = map[int]string{
-       1: "",
-
-       12345678901234567890123456789: "",
-       12345678901234567890123456789012345678: "",
-}