@@ -438,7 +438,7 @@ func f() error {
438438 require .NotContains (t , out , `"nil Message in " +` )
439439}
440440
441- func TestPipelineNext_LogCalls_ShortConcatUsesMultilineCallWhenIndented (
441+ func TestPipelineNext_LogCalls_ShortConcatSplitsStringWhenIndented (
442442 t * testing.T ) {
443443
444444 const in = `package p
@@ -472,15 +472,16 @@ func f(msg any) error {
472472 out := string (p .Format ([]byte (in )))
473473
474474 require .Contains (
475- t , out , "return " +
476- "fmt.Errorf(\n \" nil " +
477- "Message in " +
478- "SendServerEventRequest\" ,\n )" ,
475+ t , out , "return fmt.Errorf(\" nil Message in \" " +
476+ "+" +
477+ "\n " +
478+ " \" SendServerEventReq" +
479+ "uest\" )" ,
479480 )
480- require .NotContains (t , out , `"nil Message in " +` )
481+ require .NotContains (t , out , "return fmt.Errorf( \n " )
481482}
482483
483- func TestPipelineNext_LogCalls_ShortErrorfArgsUseMultilineCallWhenIndented (
484+ func TestPipelineNext_LogCalls_ShortErrorfArgsBreakBeforeArgWhenIndented (
484485 t * testing.T ) {
485486
486487 const in = `package p
@@ -512,11 +513,10 @@ func f(err error) (any, error) {
512513 out := string (p .Format ([]byte (in )))
513514
514515 require .Contains (
515- t , out , "return nil, " +
516- "fmt.Errorf(\n \" control " +
517- "block to bytes: %w\" , err,\n )" ,
516+ t , out , "return nil, fmt.Errorf(\" control block to bytes: " +
517+ "%w\" ,\n err)" ,
518518 )
519- require .NotContains (t , out , `"control block to bytes: %w",` + " \n " )
519+ require .NotContains (t , out , "return nil, fmt.Errorf( \n " )
520520}
521521
522522func TestPipelineNext_LogCalls_ShortErrorfArgsStaySingleLineWhenTheyFit (
@@ -597,6 +597,44 @@ func nodeMaxDepth(depth int) (int, error) {
597597 )
598598}
599599
600+ func TestPipelineNext_LogCalls_SplitsReturnErrorfWithoutHangingParen (
601+ t * testing.T ) {
602+
603+ const in = `package p
604+
605+ import "fmt"
606+
607+ func sum(inputs []Input) (int, error) {
608+ for i := range inputs {
609+ input := inputs[i]
610+ if input.Amount <= 0 {
611+ return 0, fmt.Errorf("input %d amount must be "+
612+ "positive", i)
613+ }
614+ }
615+
616+ return 0, nil
617+ }
618+ `
619+
620+ p := NewPipeline (PipelineConfig {
621+ ColumnLimit : 80 ,
622+ TabStop : 8 ,
623+ UseDSLLogCalls : true ,
624+ // Keep other DSL stages off to make this test focused.
625+ UseDSLMultiLineCalls : false ,
626+ UseDSLExpr : false ,
627+ UseDSLComments : false ,
628+ UseDSLFuncSigs : false ,
629+ UseDSLBlankLines : false ,
630+ })
631+
632+ out := string (p .Format ([]byte (in )))
633+
634+ require .NotContains (t , out , "fmt.Errorf(\n " )
635+ requireNoLineLongerThan (t , out , 80 )
636+ }
637+
600638func TestPipelineNext_LogCalls_FormatCompositeArgAsBlock (t * testing.T ) {
601639 const in = `package p
602640
0 commit comments