From: Sokolov Yura Date: Fri, 4 Dec 2015 17:54:24 +0000 (+0300) Subject: go/ast: remove many blank lines in SortImports X-Git-Tag: go1.6beta1~197 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=43a9e998d2d54c27066255147fd6c775532b7d31;p=gostls13.git go/ast: remove many blank lines in SortImports Currently only one blank line is checked to be removed. Changing sort.Sort may lead to more blank lines. Let's remove them all. It fixes a bug found by https://golang.org/cl/15688 Change-Id: I682cc23ecd7b10d9b6feb160da040a155297f578 Reviewed-on: https://go-review.googlesource.com/17440 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- diff --git a/src/go/ast/import.go b/src/go/ast/import.go index d2770d16cf..5c794c3e79 100644 --- a/src/go/ast/import.go +++ b/src/go/ast/import.go @@ -43,8 +43,10 @@ func SortImports(fset *token.FileSet, f *File) { if len(d.Specs) > 0 { lastSpec := d.Specs[len(d.Specs)-1] lastLine := fset.Position(lastSpec.Pos()).Line - if rParenLine := fset.Position(d.Rparen).Line; rParenLine > lastLine+1 { - fset.File(d.Rparen).MergeLine(rParenLine - 1) + rParenLine := fset.Position(d.Rparen).Line + for rParenLine > lastLine+1 { + rParenLine-- + fset.File(d.Rparen).MergeLine(rParenLine) } } }