From: Matt S Trout Date: Mon, 16 Sep 2019 19:30:32 +0000 (+0000) Subject: lift innerdent and unify algorithm X-Git-Tag: v2.000000~3^2~144 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f17bb26dd148e787e133dc8d1f1ebf2971fc983d;p=dbsrgits%2FSQL-Abstract.git lift innerdent and unify algorithm --- diff --git a/lib/SQL/Abstract/Formatter.pm b/lib/SQL/Abstract/Formatter.pm index 4b1dc3c..51645f8 100644 --- a/lib/SQL/Abstract/Formatter.pm +++ b/lib/SQL/Abstract/Formatter.pm @@ -46,11 +46,11 @@ sub _fold_sql { $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); - my $innerdent = @res - ? $next_indent - : $indent0.$self->indent_by; push @res, $line.($already ? $join : '').'('."\n"; my (undef, undef, $inner) = @$p; my $folded = $self->_fold_sql($innerdent, $innerdent, @$inner); @@ -66,7 +66,6 @@ sub _fold_sql { if (length($line = $line_proto.$j) <= $w) { next PART; } - my $innerdent = @res ? $indent : $next_indent; my $folded = $self->_fold_sql($line_proto, $innerdent, @$p); $folded =~ s/\n\Z//; push @res, $folded.($idx == $#parts ? '' : $nl_pre)."\n";