File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -390,7 +390,10 @@ func handleTrailingComma(lgs []*lineGroup) (trimTrailingComma func([]*lineGroup)
390390 }
391391 }
392392
393- if n := len (dataGroups ); n > 1 && allEndInComma (dataGroups [0 :n - 1 ]) && ! dataGroups [n - 1 ].matchesSuffix (commaLineEnd ) {
393+ commaLineEnd := regexp .MustCompile ("(,)( *)((#|//).*)?$" )
394+ commentLineEnd := regexp .MustCompile ("( *)((#|//).*)$" )
395+
396+ if n := len (dataGroups ); n > 1 && allMatchSuffix (dataGroups [0 :n - 1 ], commaLineEnd ) && ! dataGroups [n - 1 ].matchesSuffix (commaLineEnd ) {
394397 if dataGroups [n - 1 ].matchesSuffix (commentLineEnd ) {
395398 dataGroups [n - 1 ].replaceSuffix (commentLineEnd , ", $2" )
396399 } else {
@@ -414,16 +417,11 @@ func handleTrailingComma(lgs []*lineGroup) (trimTrailingComma func([]*lineGroup)
414417 return func ([]* lineGroup ) {}
415418}
416419
417- func allEndInComma (lgs []* lineGroup ) bool {
420+ func allMatchSuffix (lgs []* lineGroup , suffix * regexp. Regexp ) bool {
418421 for _ , lg := range lgs {
419- if ! lg .matchesSuffix (commaLineEnd ) {
422+ if ! lg .matchesSuffix (suffix ) {
420423 return false
421424 }
422425 }
423426 return true
424427}
425-
426- var (
427- commaLineEnd = regexp .MustCompile ("(,)( *)((#|//).*)?$" )
428- commentLineEnd = regexp .MustCompile ("( *)((#|//).*)$" )
429- )
You can’t perform that action at this time.
0 commit comments