File tree 2 files changed +39
-1
lines changed 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -546,12 +546,19 @@ func (f *fumpter) applyPre(c *astutil.Cursor) {
546
546
547
547
if f .Line (sign .Pos ()) != endLine {
548
548
handleMultiLine := func (fl * ast.FieldList ) {
549
+ // Refuse to insert a newline before the closing token
550
+ // if the list is empty or all in one line.
549
551
if fl == nil || len (fl .List ) == 0 {
550
552
return
551
553
}
554
+ fieldOpeningLine := f .Line (fl .Opening )
555
+ fieldClosingLine := f .Line (fl .Closing )
556
+ if fieldOpeningLine == fieldClosingLine {
557
+ return
558
+ }
559
+
552
560
lastFieldEnd := fl .List [len (fl .List )- 1 ].End ()
553
561
lastFieldLine := f .Line (lastFieldEnd )
554
- fieldClosingLine := f .Line (fl .Closing )
555
562
isLastFieldOnFieldClosingLine := lastFieldLine == fieldClosingLine
556
563
isLastFieldOnSigClosingLine := lastFieldLine == endLine
557
564
Original file line number Diff line number Diff line change @@ -36,6 +36,22 @@ type CombineEmbeds interface {
36
36
func Caller() {
37
37
Foo[int,int](1,2)
38
38
}
39
+
40
+ func Issue235[K interface {
41
+ comparable
42
+ constraints.Ordered
43
+ }, V any](m map[K]V) []K {
44
+ keys := maps.Keys(m)
45
+ slices.Sort(keys)
46
+ return keys
47
+ }
48
+
49
+ func multilineParams[V any](p1 V,
50
+ p2 V) {
51
+
52
+ println("body")
53
+
54
+ }
39
55
-- foo.go.golden --
40
56
package p
41
57
@@ -65,3 +81,18 @@ type CombineEmbeds interface {
65
81
func Caller() {
66
82
Foo[int, int](1, 2)
67
83
}
84
+
85
+ func Issue235[K interface {
86
+ comparable
87
+ constraints.Ordered
88
+ }, V any](m map[K]V) []K {
89
+ keys := maps.Keys(m)
90
+ slices.Sort(keys)
91
+ return keys
92
+ }
93
+
94
+ func multilineParams[V any](p1 V,
95
+ p2 V,
96
+ ) {
97
+ println("body")
98
+ }
You can’t perform that action at this time.
0 commit comments