From: Steve Hancock Date: Wed, 15 Sep 2021 13:10:43 +0000 (-0700) Subject: Fix formatting instability b1206 X-Git-Tag: 20210717.03~7 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9704cd7b605f41d189106f904fb3febf7ffdcb3b;p=perltidy.git Fix formatting instability b1206 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 9b97c452..a871aee9 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7329,6 +7329,49 @@ if ( --nowant-right-space='x' --space-function-paren +==> b1206.in <== +# S1 + +if ( + $version ge + '2.8.0' ) +{ $cons->run ( { +'-sequence' + => $aln2, +'-outseq' + => + $consoutfile + } ); +} + +# S2 + +if ( + $version ge + '2.8.0' ) +{ + $cons->run ( { + '-sequence' + => $aln2, + '-outseq' + => + $consoutfile + } ); +} + + +==> b1206.par <== +--block-brace-vertical-tightness=1 +--continuation-indentation=5 +--nodelete-old-newlines +--indent-columns=3 +--maximum-line-length=17 +--opening-brace-always-on-right +--paren-vertical-tightness-closing=1 +--space-function-paren +--stack-opening-hash-brace +--weld-nested-containers + ==> b131.in <== unless ( open( SCORE, "+>>$Score_File" ) ) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index f1a70e78..b95b0a54 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -8234,6 +8234,22 @@ sub weld_nested_containers { } + # RULE: Avoid welding under stress. The idea is that we need to have a + # little space* within a welded container to avoid instability. Note + # that after each weld the level values are reduced, so long multiple + # welds can still be made. This rule will seldom be a limiting factor + # in actual working code. Fixes b1206. + + # *the current rule is that we require a space of 'ci' + 'i' + 8, + # where 'ci' is the value of n in -ci=n and 'i' is the value in -i=n. + my $inner_level = $inner_opening->[_LEVEL_]; + my $max_len = $maximum_text_length_at_level[ $inner_level + 1 ]; + my $excess_inside_space = + $max_len - + $rOpts_continuation_indentation - + $rOpts_indent_columns - 8; + if ( $excess_inside_space <= 0 ) { next } + # Set flag saying if this pair starts a new weld my $starting_new_weld = !( @welds && $outer_seqno == $welds[-1]->[0] ); diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 16a02cea..4e28fb1d 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,14 @@ =over 4 +=item B + +Testing with random parameters produced an instability due welding with +a very short line length and large value of -ci. This is similar to issues +b1197-b1204 and fixed with a similar method. + +14 Sep 2021. + =item B Testing with random parameters produced an instability caused by misparsing