From: Steve Hancock <perltidy@users.sourceforge.net> Date: Mon, 16 Dec 2024 22:58:56 +0000 (-0800) Subject: fix rare indentation issue, c435 X-Git-Tag: 20240903.09~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=bd4c77783884020a2e0e58d4f52c4c58b8dd96fb;p=perltidy.git fix rare indentation issue, c435 --- diff --git a/dev-bin/run_convergence_tests.pl.expect b/dev-bin/run_convergence_tests.pl.expect index 20ce74ec..9f4fd7e8 100644 --- a/dev-bin/run_convergence_tests.pl.expect +++ b/dev-bin/run_convergence_tests.pl.expect @@ -5131,7 +5131,7 @@ $bc[ =sqrt ( ( $vecs**2 - )->sumover ) + )->sumover ) +0.0001; # S2 @@ -5139,7 +5139,7 @@ $bc[ =sqrt ( ( $vecs**2 - )->sumover ) + )->sumover ) +0.0001; ==> b1218 <== @@ -6410,12 +6410,12 @@ my %config = ( my $h = $integerValue->copy()->bmod( '16' - )->bstr(); + )->bstr(); my $h = $integerValue->copy()->bmod( '16' - )->bstr(); + )->bstr(); ==> b1319 <== # S1 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 185ed9e5..fba874be 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -39828,6 +39828,21 @@ sub make_paren_name { # not a closing type } + # A final check: reset the flag value from 1 to 0 if moving left would + # give this closing token less indentation than the line with its + # opening token. We could do this check at the top for more efficiency + # except for -lp. For -lp, if the $adjust_indentation flag flips from + # 1 to 2, then the -lp logic can do a better recovery if it knows that + # the $default_adjust_indentation=1 instead of 0 (c435) + if ( $adjust_indentation == 1 ) { + my $no_left_adjustment_space = defined($opening_indentation) + && get_spaces($leading_spaces_beg) <= + get_spaces($opening_indentation); + if ($no_left_adjustment_space) { + $adjust_indentation = 0; + } + } + return ( $adjust_indentation, diff --git a/t/snippets/expect/break_old_methods.break_old_methods b/t/snippets/expect/break_old_methods.break_old_methods index 943f5a61..ce39954c 100644 --- a/t/snippets/expect/break_old_methods.break_old_methods +++ b/t/snippets/expect/break_old_methods.break_old_methods @@ -5,4 +5,4 @@ my $q = $rs { 'track.id' => { -ident => 'none_search.id' }, } -)->as_query; + )->as_query; diff --git a/t/snippets15.t b/t/snippets15.t index eac77b01..21f4498a 100644 --- a/t/snippets15.t +++ b/t/snippets15.t @@ -289,7 +289,7 @@ my $q = $rs { 'track.id' => { -ident => 'none_search.id' }, } -)->as_query; + )->as_query; #6........... },