From b38ccfc90998f2f5182ab237cea9b2fcc7c786c3 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 28 Jul 2021 06:13:38 -0700 Subject: [PATCH] Fix edge case of formatting instability --- dev-bin/run_convergence_tests.pl.data | 60 +++++++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 12 ++++-- local-docs/BugLog.pod | 14 ++++++- 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index f8a4a54e..58d19d65 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -6691,6 +6691,66 @@ my $plugin = Koha::FrameworkPlugin->new( { --maximum-line-length=60 --stack-closing-paren +==> b1180.in <== +# S1 +$orders + = SearchOrders( { + ordernumber => + $ordernumber + } ) ; + +# S2 +$orders= SearchOrders( { + ordernumber => + $ordernumber + } ); + + +==> b1180.par <== +--indent-columns=3 +--maximum-line-length=24 +--continuation-indentation=9 +--weld-nested-containers +--want-break-before='=' +--nowant-left-space='=' +--closing-token-indentation=3 +--stack-opening-hash-brace +--vertical-tightness-closing=2 + +==> b1181.in <== +# S1 + $marc + = GetISBDView( { + 'record' + => $marc, +'template' + => 'opac', +'framework' + => $framework, + } ) ; + +# S2 + $marc= GetISBDView( { + 'record' => + $marc, + 'template' => +'opac', + 'framework' => + $framework, + } ) ; + + +==> b1181.par <== +--continuation-indentation=9 +--extended-continuation-indentation +--indent-columns=3 +--maximum-line-length=24 +--nowant-left-space='+ <<= /= = != > -= %= -= & <<= >= * >= <<= x !~' +--paren-vertical-tightness-closing=2 +--stack-opening-hash-brace +--want-break-before='**= <<= -= * ^= &= =~ .= = * ||= > / = &= *= &=' +--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 4cd319d8..240681fd 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -7719,8 +7719,12 @@ sub weld_nested_containers { my $iline_outer_opening = -1; my $weld_count_this_start = 0; - my $multiline_tol = - 1 + max( $rOpts_indent_columns, $rOpts_continuation_indentation ); + # $single_line_tol added to fix cases b1180 b1181 + my $single_line_tol = + $rOpts_continuation_indentation > $rOpts_indent_columns ? 1 : 0; + + my $multiline_tol = $single_line_tol + 1 + + max( $rOpts_indent_columns, $rOpts_continuation_indentation ); my $length_to_opening_seqno = sub { my ($seqno) = @_; @@ -8043,8 +8047,8 @@ EOM # We can use zero tolerance if it looks like we are working on an # existing weld. my $tol = - $is_one_line_weld || $is_multiline_weld - ? 0 + $is_one_line_weld || $is_multiline_weld + ? $single_line_tol : $multiline_tol; # By how many characters does this exceed the text window? diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index f1cdc77b..e3c1596b 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,16 @@ =over 4 +=item B. + +Random testing with random input parameters produced cases of formatting +instability involving welding with unusual parameter settings. This update +makes a small tolarance adjustment to fix it. + +This fixes cases b1180 b1181. + +28 Jul 2021. + =item B This update fixes an extremely rare problem in formatting nested ternary @@ -52,7 +62,7 @@ statements, illustrated in the following snippet: ), ); -This fixes issue c050. +This fixes issue c050, 63784d8. 22 Jul 2021. @@ -85,7 +95,7 @@ The stable state is then This fixes case b1179. -21 Jul 2021. +21 Jul 2021, 4ecc078. =item B -- 2.39.5