From: Matt S Trout Date: Mon, 16 Sep 2019 19:22:41 +0000 (+0000) Subject: better indent picking inside parens X-Git-Tag: v2.000000~3^2~145 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4be609c37cf6cd681a63ff7948f93b274154044a;p=dbsrgits%2FSQL-Abstract.git better indent picking inside parens --- diff --git a/lib/SQL/Abstract/Formatter.pm b/lib/SQL/Abstract/Formatter.pm index efbd912..4b1dc3c 100644 --- a/lib/SQL/Abstract/Formatter.pm +++ b/lib/SQL/Abstract/Formatter.pm @@ -48,9 +48,12 @@ sub _fold_sql { } 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($next_indent, $next_indent, @$inner); + my $folded = $self->_fold_sql($innerdent, $innerdent, @$inner); $folded =~ s/\n\Z//; push @res, $folded."\n"; $line_orig = $line