From 9fa1b2941869278230220bb6d5c2b2c7c0a7a408 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 9 May 2024 07:08:26 -0700 Subject: [PATCH] fix b1469 --- dev-bin/run_convergence_tests.pl.data | 26 +++++++++++++++++++++++++ dev-bin/run_convergence_tests.pl.expect | 23 ++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 10 +++++++++- 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 04663be9..f795902f 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -12075,6 +12075,32 @@ foreach $n ( --block-brace-vertical-tightness=1 --nodelete-old-newlines +==> b1469.in <== +my @outer = + ( + [ + 'a1', 'a2', 'a3', + ], [ + 'b1', 'b2', 'b3', + ], [ + 'c1', 'c2', 'c3', + ], + ); + +my @outer = ( + [ 'a1', 'a2', 'a3', ], + [ 'b1', 'b2', 'b3', ], + [ 'c1', 'c2', 'c3', ], +); + +==> b1469.par <== +--maximum-line-length=35 +--indent-columns=1 +--continuation-indentation=8 +--extended-continuation-indentation +--break-before-paren=2 +--opening-square-bracket-right + ==> b148.in <== # state 1 @yydgoto=( diff --git a/dev-bin/run_convergence_tests.pl.expect b/dev-bin/run_convergence_tests.pl.expect index cbad2352..2b3ab805 100644 --- a/dev-bin/run_convergence_tests.pl.expect +++ b/dev-bin/run_convergence_tests.pl.expect @@ -8188,6 +8188,29 @@ foreach $n ( } } +==> b1469 <== +my @outer = + ( + [ + 'a1', 'a2', 'a3', + ], [ + 'b1', 'b2', 'b3', + ], [ + 'c1', 'c2', 'c3', + ], + ); + +my @outer = + ( + [ + 'a1', 'a2', 'a3', + ], [ + 'b1', 'b2', 'b3', + ], [ + 'c1', 'c2', 'c3', + ], + ); + ==> b148 <== # state 1 @yydgoto=( diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index b27a2768..d636ca50 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -17480,10 +17480,18 @@ sub break_before_list_opening_containers { # decide if a list is complex. For now it is only applied when -lp # and -vmll are used, but eventually it may become the standard method. # Fixes b1274, b1275, and others, including b1099. + # Update: case b1469 also had this type of problem; it had the + # combination ci>i and used -xci. This is just a band-aid; eventually + # it might be best if all cases use this logic, but that would change + # existing formatting. if ( $break_option == 2 ) { + my $b1469 = $rOpts_continuation_indentation > $rOpts_indent_columns + && $rOpts_extended_continuation_indentation; + if ( $rOpts_line_up_parentheses - || $rOpts_variable_maximum_line_length ) + || $rOpts_variable_maximum_line_length + || $b1469 ) { # Start with the basic definition of a complex list... -- 2.39.5