summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-07-29 16:23:17 -0700
committerRobert Griesemer <gri@golang.org>2009-07-29 16:23:17 -0700
commit297317cfed550069aeb8442f968d5cdcec9908aa (patch)
tree504a7bbf2b3c189d742b4b428b4ce0eb4062549d /src
parent83594f233ece95e51d4d1bbfdab5daed14b91c11 (diff)
downloadgolang-297317cfed550069aeb8442f968d5cdcec9908aa.tar.gz
break tabwriter columns when starting a new block of indented statements
R=r DELTA=16 (15 added, 0 deleted, 1 changed) OCL=32475 CL=32481
Diffstat (limited to 'src')
-rw-r--r--src/pkg/go/printer/printer.go2
-rw-r--r--src/pkg/go/printer/testdata/golden1.go7
-rw-r--r--src/pkg/go/printer/testdata/source1.go8
3 files changed, 16 insertions, 1 deletions
diff --git a/src/pkg/go/printer/printer.go b/src/pkg/go/printer/printer.go
index b3de0d2e1..6e6f3a1b5 100644
--- a/src/pkg/go/printer/printer.go
+++ b/src/pkg/go/printer/printer.go
@@ -681,7 +681,7 @@ func (p *printer) decl(decl ast.Decl) (comment *ast.CommentGroup, optSemi bool)
// Print the statement list indented, but without a newline after the last statement.
func (p *printer) stmtList(list []ast.Stmt) {
if len(list) > 0 {
- p.print(+1, newline);
+ p.print(+1, formfeed); // the next lines have different structure
optSemi := false;
for i, s := range list {
if i > 0 {
diff --git a/src/pkg/go/printer/testdata/golden1.go b/src/pkg/go/printer/testdata/golden1.go
index b44eb6c49..b36497f25 100644
--- a/src/pkg/go/printer/testdata/golden1.go
+++ b/src/pkg/go/printer/testdata/golden1.go
@@ -50,3 +50,10 @@ func f1() {
/* 4 */
f0()
}
+
+func abs(x int) int {
+ if x < 0 { // the tab printed before this comment's // must not affect the remaining lines
+ return -x // this statement should be properly indented
+ }
+ return x
+}
diff --git a/src/pkg/go/printer/testdata/source1.go b/src/pkg/go/printer/testdata/source1.go
index f96746a70..b0a9c71eb 100644
--- a/src/pkg/go/printer/testdata/source1.go
+++ b/src/pkg/go/printer/testdata/source1.go
@@ -50,3 +50,11 @@ func f1() {
/* 4 */
f0();
}
+
+
+func abs(x int) int {
+ if x < 0 { // the tab printed before this comment's // must not affect the remaining lines
+ return -x; // this statement should be properly indented
+ }
+ return x;
+}