From 05f240096f1cbd1398a5a10f4b11ec74b986aa3a Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 7 Jul 2022 10:26:29 -0700 Subject: [PATCH] fix b1371 --- dev-bin/run_convergence_tests.pl.data | 33 +++++++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 19 ++++++++------- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index eba60ede..9ef02cc5 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -10110,6 +10110,39 @@ my ( $m, $i, $j ) =( --nowant-right-space='=' --want-break-before='=' +==> b1371.in <== +# S1 +my ( +$xpos, +$ypos, +$font_size +) =( + 100, + 700, + 12 +); + +# S2 +my ( +$xpos, +$ypos, +$font_size + ) + =( + 100, + 700, + 12 + ); + + +==> b1371.par <== +--break-before-all-operators +--extended-line-up-parentheses +--indent-columns=0 +--keep-old-breakpoints-before=' )' +--maximum-line-length=12 +--nowant-right-space='=' + ==> b140.in <== $cmd[ $i ]=[ $s, $e, $cmd, \@hunk, $i ] ; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 5dce2462..9bcd31a3 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -21828,17 +21828,20 @@ sub get_available_spaces_to_go { # find the position if we break at the '=' my $i_test = $ii_last_equals; - # Fix for issue b1229, check for break before - # Fix for issue b1356, i_test must never be blank + # Fix for issue b1229, check if want break before this token + # Fix for issue b1356, if i_test is a blank, the leading spaces may + # be incorrect (if it was an interline blank). # Fix for issue b1357 .. b1370, i_test must be prev nonblank # ( the ci value for blanks can vary ) - # See also b223 + # See also case b223 + # Fix for issue b1371-b1374 : all of these and the above are fixed + # by simply backing up one index and setting the leading spaces of + # a blank equal to that of the equals. if ( $want_break_before{ $types_to_go[$i_test] } ) { - my $i_prev_nb = $i_test - 1; - $i_prev_nb -= 1 - if ( $types_to_go[$i_prev_nb] eq 'b' ); - $i_test = $i_prev_nb - if ( $i_prev_nb > $ii_begin_line ); + $i_test -= 1; + $leading_spaces_to_go[$i_test] = + $leading_spaces_to_go[$ii_last_equals] + if ( $types_to_go[$i_test] eq 'b' ); } elsif ( $types_to_go[ $i_test + 1 ] eq 'b' ) { $i_test++ } -- 2.39.5