]> Cypherpunks repositories - gostls13.git/commitdiff
break tabwriter columns when starting a new block of indented statements
authorRobert Griesemer <gri@golang.org>
Wed, 29 Jul 2009 23:23:17 +0000 (16:23 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 29 Jul 2009 23:23:17 +0000 (16:23 -0700)
R=r
DELTA=16  (15 added, 0 deleted, 1 changed)
OCL=32475
CL=32481

src/pkg/go/printer/printer.go
src/pkg/go/printer/testdata/golden1.go
src/pkg/go/printer/testdata/source1.go

index b3de0d2e1b335623d06860b21b8f62c4fc259e6d..6e6f3a1b5ecd409ed3a19b8695d67b6ffc3c1acd 100644 (file)
@@ -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 {
index b44eb6c49ba60be7e69bd6647e41b0e5bccde265..b36497f255f4f7464f41deee4f1dccd3a3e18de9 100644 (file)
@@ -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
+}
index f96746a70284f8faa7165ab23e3ef2d3f4aaf825..b0a9c71eb06c70197dc58befba8d63b784297fd7 100644 (file)
@@ -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;
+}