From 816ff23e42272b91dfcf108cf6bf9ce260236d98 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 20 Mar 2022 13:13:08 -0700 Subject: [PATCH] fix rare formatting issue b1325 --- dev-bin/run_convergence_tests.pl.data | 31 +++++++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 27 +++++++++++------------ 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 6dfdeffa..cef8fa0c 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -9486,6 +9486,37 @@ my $parser = --indent-columns=0 --maximum-line-length=53 +==> b1325.in <== +WriteMakefile( + PREREQ_PM => { + 'Tk' =>'800.025', + 'Tk::DiffText' => 0, + 'Perl::Tidy' => 0, # comes in the perltidy application + 'Log::Log4perl' => '1.0', + 'version' => 0, # used to detect old Tk's and use different widgets where required + }, +); + +WriteMakefile( + PREREQ_PM => { + 'Tk' => + '800.025', + 'Tk::DiffText' => 0, + 'Perl::Tidy' => 0, # comes in the perltidy application + 'Log::Log4perl' => '1.0', + 'version' => 0, # used to detect old Tk's and use different widgets where required + }, +); + +==> b1325.par <== +--noadd-whitespace +--continuation-indentation=6 +--extended-continuation-indentation +--extended-line-up-parentheses +--indent-columns=3 +--maximum-line-length=33 +--variable-maximum-line-length + ==> b1327.in <== @where= $self->_where()->where_clause( diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index f73a4508..bf690481 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1512,20 +1512,6 @@ EOM } } - #------------------------------------------------------------------- - # The combination -xlp and -vmll can be unstable unless -iscl is set - #------------------------------------------------------------------- - # This is a temporary fix for issue b1310. FIXME: look for a better fix. - # No longer needed for b1302, b1306. - if ( $rOpts->{'variable-maximum-line-length'} - && $rOpts->{'extended-line-up-parentheses'} - && !$rOpts->{'ignore-side-comment-lengths'} ) - { - $rOpts->{'ignore-side-comment-lengths'} = 1; - - # we could write a warning here - } - #----------------------------------------------------------- # The combination -lp -vmll can be unstable if -ci<2 (b1267) #----------------------------------------------------------- @@ -10807,6 +10793,7 @@ sub collapsed_lengths { my $ris_permanently_broken = $self->[_ris_permanently_broken_]; my $ris_list_by_seqno = $self->[_ris_list_by_seqno_]; my $rhas_broken_list = $self->[_rhas_broken_list_]; + my $rtype_count_by_seqno = $self->[_rtype_count_by_seqno_]; my $K_start_multiline_qw; my $level_start_multiline_qw = 0; @@ -11017,6 +11004,18 @@ sub collapsed_lengths { # stabilize by itself after one or two iterations. # - So, not doing this for now + # Turn off the interrupted list rule if -vmll is set and a + # list has '=>' characters. This avoids instabilities due + # to dependence on old line breaks; issue b1325. + if ( $interrupted_list_rule + && $rOpts_variable_maximum_line_length ) + { + my $rtype_count = $rtype_count_by_seqno->{$seqno}; + if ( $rtype_count && $rtype_count->{'=>'} ) { + $interrupted_list_rule = 0; + } + } + # Include length to a comma ending this line if ( $interrupted_list_rule && $rLL->[$K_terminal]->[_TYPE_] eq ',' ) -- 2.39.5