File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -467,13 +467,19 @@ func (f *fumpter) applyPre(c *astutil.Cursor) {
467
467
specEnd := node .Specs [0 ].End ()
468
468
469
469
if len (f .commentsBetween (node .TokPos , specPos )) > 0 {
470
- // If the single spec has any comment, it must
471
- // go before the entire declaration now.
470
+ // If the single spec has a comment on the line above,
471
+ // the comment must go before the entire declaration now.
472
472
node .TokPos = specPos
473
473
} else {
474
474
f .removeLines (f .Line (node .TokPos ), f .Line (specPos ))
475
475
}
476
- f .removeLines (f .Line (specEnd ), f .Line (node .Rparen ))
476
+ if len (f .commentsBetween (specEnd , node .Rparen )) > 0 {
477
+ // Leave one newline to not force a comment on the next line to
478
+ // become an inline comment.
479
+ f .removeLines (f .Line (specEnd )+ 1 , f .Line (node .Rparen ))
480
+ } else {
481
+ f .removeLines (f .Line (specEnd ), f .Line (node .Rparen ))
482
+ }
477
483
478
484
// Remove the parentheses. go/printer will automatically
479
485
// get rid of the newlines.
Original file line number Diff line number Diff line change 41
41
"bar",
42
42
}
43
43
)
44
+
45
+ var (
46
+ foo = "foo"
47
+ // bar = "bar"
48
+ // baz = "baz"
49
+ )
44
50
-- f1.go.golden --
45
51
package p
46
52
@@ -73,6 +79,11 @@ var multiline = []string{
73
79
"foo",
74
80
"bar",
75
81
}
82
+
83
+ var foo = "foo"
84
+
85
+ // bar = "bar"
86
+ // baz = "baz"
76
87
-- f2.go --
77
88
package p
78
89
You can’t perform that action at this time.
0 commit comments