segmentio / golines

A golang formatter that fixes long lines
MIT License
903 stars 56 forks source link

Struct literals are not broken down if there are already line breaks #131

Open bgimby opened 3 months ago

bgimby commented 3 months ago

golines currently leaves this alone, even though it correctly tags it with a shorten annotation:

var _ = &mybigtype{
    arg1: "biglongstring1", arg2: longfunctioncall(param1), arg3: []string{"list1"}, arg4: bigvariable,
}
% golines  _fixtures/struct_split.go --keep-annotations
var _ = &mybigtype{
    // __golines:shorten:103
    arg1: "biglongstring1", arg2: longfunctioncall(param1), arg3: []string{"list1"}, arg4: bigvariable,
}

Ideally, it should split each arg onto its own line:

var _ = &mybigtype{
    arg1: "biglongstring1",
    arg2: longfunctioncall(param1),
    arg3: []string{"list1"},
    arg4: bigvariable,
}