]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix issue b1215, rare formatting instability
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 4 Oct 2021 20:32:41 +0000 (13:32 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 4 Oct 2021 20:32:41 +0000 (13:32 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index e972075c9778a54a43f662bb86dd9fcfb0e7076f..06a9c8898643a082dc15263a5512899eba4a7a02 100644 (file)
@@ -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(
index ff1f90e5370cba2c21539b6209115984b84f6f92..df8f477a12a809811833f4d2421e5e0fb416d840 100644 (file)
@@ -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;
             }