From 43a9e998d2d54c27066255147fd6c775532b7d31 Mon Sep 17 00:00:00 2001 From: Sokolov Yura Date: Fri, 4 Dec 2015 20:54:24 +0300 Subject: [PATCH] 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 --- src/go/ast/import.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) } } } -- 2.50.0