diff --git a/format/format.go b/format/format.go index 727acce..59a168e 100644 --- a/format/format.go +++ b/format/format.go @@ -316,13 +316,12 @@ func (f *fumpter) applyPre(c *astutil.Cursor) { switch node := c.Node().(type) { case *ast.File: // Join contiguous lone var/const/import lines. - // Abort if there are empty lines or comments in between, - // including a leading comment, which could be a directive. + // Abort if there are empty lines or comments in between. newDecls := make([]ast.Decl, 0, len(node.Decls)) for i := 0; i < len(node.Decls); { newDecls = append(newDecls, node.Decls[i]) start, ok := node.Decls[i].(*ast.GenDecl) - if !ok || isCgoImport(start) || start.Doc != nil { + if !ok || isCgoImport(start) { i++ continue } diff --git a/testdata/scripts/decl-group-many.txt b/testdata/scripts/decl-group-many.txt index 0678b6e..3b1c323 100644 --- a/testdata/scripts/decl-group-many.txt +++ b/testdata/scripts/decl-group-many.txt @@ -59,9 +59,8 @@ var v1 = "mixed" const c1 = "mixed" // comment, e.g. directive -var v1 = 's' - var ( + v1 = 's' v2 = 'd' v3 = 'd' )