Skip to content

Commit

Permalink
go/ast: remove many blank lines in SortImports
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
funny-falcon authored and rsc committed Dec 4, 2015
1 parent a8d9c31 commit 43a9e99
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/go/ast/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 43a9e99

Please sign in to comment.