summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
+}