$line .= $j_part;
next PART;
}
+ my $innerdent = @res
+ ? $next_indent
+ : $indent0.$self->indent_by;
if (ref($p) and $p->[1] eq '(' and $p->[-1] eq ')') {
my $already = !($line eq $indent0 or $line eq $line_orig);
push @res, $line.($already ? $join : '').'('."\n";
my (undef, undef, $inner) = @$p;
- my $folded = $self->_fold_sql($next_indent, $next_indent, @$inner);
+ my $folded = $self->_fold_sql($innerdent, $innerdent, @$inner);
$folded =~ s/\n\Z//;
push @res, $folded."\n";
$line_orig = $line
- = $indent0.')'.(
- ($nl_post and $idx < $#parts) ? ' '.$nl_post : ' '
- );
+ = $indent0.')'.($idx == $#parts ? '' : $join);
next PART;
}
- push @res, $line.$nl_pre."\n" if $line ne $line_orig;
+ if ($line ne $line_orig) {
+ push @res, $line.($idx == $#parts ? '' : $nl_pre)."\n";
+ }
if (length($line = $line_proto.$j) <= $w) {
- $line_proto = $line;
next PART;
}
- my $innerdent = @res ? $indent : $next_indent;
my $folded = $self->_fold_sql($line_proto, $innerdent, @$p);
$folded =~ s/\n\Z//;
- push @res, $folded.$nl_pre."\n";
+ push @res, $folded.($idx == $#parts ? '' : $nl_pre)."\n";
$line_orig = $line = $idx == $#parts ? '' : $line_proto;
}
return join '', @res, $line;