From 4f293574638fda763e172dfa777456fed2c60172 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Mon, 8 Nov 2021 06:19:29 -0800 Subject: [PATCH] fix b1240, rare instability formatting under stress --- dev-bin/run_convergence_tests.pl.data | 20 ++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index dc64ae23..4822b548 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -8011,6 +8011,26 @@ is( --space-keyword-paren --weld-nested-containers +==> b1240.in <== +# S1 + printf( +"Inode Last Change at: %s\n", + scalar + localtime($ctime) ); +# S2 + printf( +"Inode Last Change at: %s\n", + scalar localtime( + $ctime) + ); + +==> b1240.par <== +--continuation-indentation=3 +--extended-continuation-indentation +--indent-columns=5 +--line-up-parentheses +--maximum-line-length=34 + ==> b1241.in <== # created from b901 # Started blinking with new -lp logic diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 659036fa..f38cba87 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -17660,6 +17660,16 @@ EOM # Do not break hash braces under stress (fixes b1238) $do_not_break_apart ||= $types_to_go[$i_opening] eq 'L'; + + # This option fixes b1235, b1237, b1240 with old and new -lp, + # but formatting is nicer with next option. + ## $is_long_term ||= + ## $levels_to_go[$i_opening] > $stress_level + 1; + + # This option fixes b1240 but not b1235, b1237 with new -lp, + # but this gives better formatting than the previous option. + $do_not_break_apart ||= + $levels_to_go[$i_opening] > $stress_level; } if ( !$is_long_term -- 2.39.5