From: Steve Hancock Date: Sun, 1 Aug 2021 14:44:24 +0000 (-0700) Subject: Fix edge case of formatting instability, b1185 X-Git-Tag: 20210717.02~67 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d2ab2b70502fd92c0c128c3f3e009b96dd60fa1c;p=perltidy.git Fix edge case of formatting instability, b1185 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 134a138a..2fe5c841 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -6904,6 +6904,33 @@ ok( ( Win32::GetFullPathName( --weld-nested-containers --vertical-tightness=2 +==> b1185.in <== +# S1 + my $visible_items = { + map { $_->itemnumber => $_ } + $biblio->items + ->filter_by_visible_in_opac + ( { patron => $patron } ) + ->as_list + }; +#S2 + my $visible_items = { + map { $_->itemnumber => $_ } + $biblio->items + ->filter_by_visible_in_opac + ( { patron => + $patron + } + )->as_list + }; + +==> b1185.par <== +--indent-columns=10 +--line-up-parentheses +--maximum-line-length=44 +--vertical-tightness=2 +--weld-nested-containers + ==> b120.in <== # Same as bug96 # State 1 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 6b9965bf..d2d1bc52 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -7548,11 +7548,21 @@ sub setup_new_weld_measurements { # breaks. $self->[_ris_essential_old_breakpoint_]->{$Kprev} = 1; + # Avoid measuring from between an opening paren and a previous token + # which should stay close to it ... fixes b1185 + my $token_oo = $rLL->[$Kouter_opening]->[_TOKEN_]; + my $type_prev = $rLL->[$Kprev]->[_TYPE_]; + if ( $Kouter_opening == $Kfirst + && $token_oo eq '(' + && $has_tight_paren{$type_prev} ) + { + $Kref = $Kprev; + } + # Back up and count length from a token like '=' or '=>' if -lp # is used (this fixes b520) # ...or if a break is wanted before there - my $type_prev = $rLL->[$Kprev]->[_TYPE_]; - if ( $rOpts_line_up_parentheses + elsif ($rOpts_line_up_parentheses || $want_break_before{$type_prev} ) { @@ -13300,9 +13310,9 @@ sub insert_additional_breaks { sub in_same_container_i { - # check to see if tokens at i1 and i2 are in the same container, and not - # separated by certain characters: => , ? : || or This is an interface - # between the _to_go arrays to the rLL array + # Check to see if tokens at i1 and i2 are in the same container, and + # not separated by certain characters: => , ? : || or + # This is an interface between the _to_go arrays to the rLL array my ( $self, $i1, $i2 ) = @_; # quick check diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 076b3bdb..dadd9848 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,15 @@ =over 4 +=item B. + +Testing with random parameters produced a case of welding instability involving +parameters -wn, -vt=2, -lp and a short maximum line length. + +This fixes case b1185. + +1 Aug 2021. + =item B. Testing with random parameters produced a case of welding instability involving