]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1231, rare instability involving -bbp=3 -bbpi=2 -iob -xci
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 24 Oct 2021 01:03:52 +0000 (18:03 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 24 Oct 2021 01:03:52 +0000 (18:03 -0700)
CHANGES.md
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 7621f46efc873cf1105fd999b2ec88938a65c4ef..5ae134bd45a0a31cd3daa61f25e721fa37d72d9c 100644 (file)
@@ -2,7 +2,7 @@
 
 ## 2021 07 17.04
 
-    - Added two new parameters to control the block types to which the
+    - Two new parameters were added to control the block types to which the
       -bl (--opening-brace-on-new-line) flag applies.  The new parameters are
       -block-left-list=s, or -bll=s, and --block-left-exclusion-list=s,
       or -blxl=s.  Previously the -bl flag was 'hardwired' to apply to
       the controls.  If you want to recover the exact previous default behavior of
       the -bli then add the -bl flag.
 
-    - Partial fix issue for git #74, the -lp formatting style was
+    - A partial fix was made for issue for git #74. The -lp formatting style was
       being lost when a one-line anonymous sub was followed by a closing brace.
 
-    - Fix issue git #73, the -nfpva flag was not working correctly.
+    - Fixed issue git #73, in which the -nfpva flag was not working correctly.
       Some unwanted vertical alignments of spaced function perens
       were being made.
 
@@ -33,8 +33,8 @@
       comment, '#>>V', can be lost.  A workaround for the previous version
       is to include the parameter '-mbl=2'.
 
-    - Vertical alignment of function calls without parens has been improved
-      and is now closer to alignment results with parens.  For example
+    - Vertical alignment of function calls without parens has been improved and
+      in many cases is closer to what alignment would be if parens had been used.
 
         # OLD
         mkTextConfig $c, $x, $y, -anchor => 'se', $color;
     - This version runs 10 to 15 percent faster on large files than the
       previous release due to optimizations made with the help of NYTProf.
 
-    - This version was subjected to over 200 cpu hours of testing with random input
-      parameters with no instabilities (metastable states) or other irregularities
-      seen.
-
     - Numerous minor fixes have been made, mostly very rare formatting instabilities
-      found in random testing. A complete list is at:
+      found in random testing. An effort has been made to minimize changes to
+      existing formatting, but some changes will invariably occur. Many of these
+      updates are listed at:
 
            https://github.com/perltidy/perltidy/blob/master/local-docs/BugLog.pod
 
index 4fb952226cfd54f8601429638580ecdbfc54b489..4b9f724bfb55869e552a0b8071168c3e5a8e49e2 100644 (file)
@@ -7799,6 +7799,38 @@ $obj= {foo => sub { "bar" ; }
 --vertical-tightness=2
 --weld-nested-containers
 
+==> b1231.in <==
+# S1
+@data =
+         (
+          [
+           "1st", "2nd", "3rd", "4th",
+           "5th", "6th", "7th", "8th",
+           "9th"
+          ],
+          [
+           1, 2, 5, 6, 3, 1.5, 1, 3, 4
+          ],
+         );
+# S2
+@data =
+ (
+ [
+  "1st", "2nd", "3rd", "4th", "5th", "6th",
+  "7th", "8th", "9th"
+ ],
+ [ 1, 2, 5, 6, 3, 1.5, 1, 3, 4 ],
+ );
+
+==> b1231.par <==
+--break-before-paren-and-indent=2
+--break-before-paren=3
+--continuation-indentation=9
+--extended-continuation-indentation
+--ignore-old-breakpoints
+--indent-columns=1
+--maximum-line-length=47
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
index 41459647fe5abd991b52ca425f9ca7a6db0ad31a..794d5e29d80ed0ba6aa347c3a541dee2be00c94d 100644 (file)
@@ -9451,7 +9451,10 @@ sub break_before_list_opening_containers {
     my $length_tol =
       max( 1, $rOpts_continuation_indentation, $rOpts_indent_columns );
     if ($rOpts_ignore_old_breakpoints) {
-        $length_tol += $rOpts_maximum_line_length;
+
+        # Patch suggested by b1231; the old tol was excessive.
+        ## $length_tol += $rOpts_maximum_line_length;
+        $length_tol *= 2;
     }
 
     my $rbreak_before_container_by_seqno = {};
@@ -9507,6 +9510,14 @@ sub break_before_list_opening_containers {
 
         my $ci = $rLL->[$KK]->[_CI_LEVEL_];
 
+        # Fix for b1231: the has_list_with_lec does not cover all cases.
+        # A broken container containing a list and with line-ending commas
+        # will stay broken, so can be treated as if it had a list with lec.
+        $has_list_with_lec ||=
+             $has_list
+          && $ris_broken_container->{$seqno}
+          && $rlec_count_by_seqno->{$seqno};
+
         DEBUG_BBX
           && print STDOUT
 "BBX: Looking at seqno=$seqno, token = $token with option=$break_option\n";