From 0bb9793cbb1f0a761e4a44da3e43b1a1e0177c50 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 26 Jun 2022 07:49:51 -0700 Subject: [PATCH] fix issue b1355 --- dev-bin/run_convergence_tests.pl.data | 20 ++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 9 ++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index d8c3e378..29c1534c 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -9973,6 +9973,26 @@ while (my ( $sid, $u, $lasttime )= --indent-columns=9 --maximum-line-length=35 +==> b1355.in <== +# S1 +my $data = [ + { value => "Tom" }, + { value => 33 }, + { value => "Sales" }, +]; + +# S2 +my $data = + [ { value => "Tom" }, { value => 33 }, { value => "Sales" }, ]; + + +==> b1355.par <== +--break-before-square-bracket-and-indent=2 +--break-before-square-bracket=2 +--continuation-indentation=9 +--indent-columns=1 +--maximum-line-length=72 + ==> b140.in <== $cmd[ $i ]=[ $s, $e, $cmd, \@hunk, $i ] ; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index afc947a3..4ad43c63 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1582,10 +1582,13 @@ EOM # (1) -lp is not compatible with opt=2, silently set to opt=0 # (2) opt=0 and 2 give same result if -i=-ci; but opt=0 is faster + # (3) set opt=0 if -i < -ci (can be unstable, case b1355) if ( $opt == 2 ) { - if ( $rOpts->{'line-up-parentheses'} - || $rOpts->{'indent-columns'} == - $rOpts->{'continuation-indentation'} ) + if ( + $rOpts->{'line-up-parentheses'} + || ( $rOpts->{'indent-columns'} <= + $rOpts->{'continuation-indentation'} ) + ) { $opt = 0; } -- 2.39.5