From e14be3a6262ccedf083a881925a4c812a7fa9910 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Mon, 4 Oct 2021 13:32:41 -0700 Subject: [PATCH] fix issue b1215, rare formatting instability --- dev-bin/run_convergence_tests.pl.data | 29 +++++++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 7 +++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index e972075c..06a9c889 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7480,6 +7480,35 @@ $bc[ --variable-maximum-line-length --weld-nested-containers +==> b1215.in <== +# S1 + my $dists + =sqrt ( + ( + $vecs**2 + )->sumover + ) + +0.0001; + +# S2 + my $dists + =sqrt ( + ( $vecs**2 + )->sumover ) + +0.0001; + +==> b1215.par <== +--break-at-old-method-breakpoints +--continuation-indentation=4 +--indent-columns=2 +--line-up-parentheses +--maximum-line-length=12 +--nowant-right-space='+ =' +--paren-vertical-tightness=1 +--space-keyword-paren +--variable-maximum-line-length +--want-break-before='= +' + ==> b1218.in <== # S1 is( diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index ff1f90e5..df8f477a 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -7345,13 +7345,16 @@ sub keep_old_line_breaks { # Patch to avoid blinkers: but do not do this unless the # container holds a list, or the opening and closing parens are - # separated by more than one line. + # separated by more than one* line. # Fixes case b977. + # *To fix b1215: use min line count = 2 if -vt=n to avoid + # oscillations with function of opening vertical tightness. + my $lc_min = $opening_vertical_tightness{$token} ? 2 : 1; next if ( !$ris_list_by_seqno->{$seqno} && ( !$ris_broken_container->{$seqno} - || $ris_broken_container->{$seqno} <= 1 ) + || $ris_broken_container->{$seqno} <= $lc_min ) ); $rwant_container_open->{$seqno} = 1; } -- 2.39.5