From 28592ee1ea1f5cdffcf85472f9de0285d928cf12 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Wed, 3 Aug 2011 16:54:30 +0200 Subject: Imported Upstream version 59 --- src/pkg/go/printer/nodes.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/pkg/go/printer/nodes.go') diff --git a/src/pkg/go/printer/nodes.go b/src/pkg/go/printer/nodes.go index 0fca8a161..f2b79d810 100644 --- a/src/pkg/go/printer/nodes.go +++ b/src/pkg/go/printer/nodes.go @@ -1158,8 +1158,14 @@ func (p *printer) stmt(stmt ast.Stmt, nextIsRBrace bool, multiLine *bool) { case *ast.SelectStmt: p.print(token.SELECT, blank) - p.block(s.Body, 0) - *multiLine = true + body := s.Body + if len(body.List) == 0 && !p.commentBefore(p.fset.Position(body.Rbrace)) { + // print empty select statement w/o comments on one line + p.print(body.Lbrace, token.LBRACE, body.Rbrace, token.RBRACE) + } else { + p.block(body, 0) + *multiLine = true + } case *ast.ForStmt: p.print(token.FOR) -- cgit v1.2.3