]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix formatting instability b1206
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 15 Sep 2021 13:10:43 +0000 (06:10 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 15 Sep 2021 13:10:43 +0000 (06:10 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 9b97c452236f1df50d3c5896f39cf632caa66bde..a871aee927b245c6878a521189cf58995e46d6fb 100644 (file)
@@ -7329,6 +7329,49 @@ if (
 --nowant-right-space='x'
 --space-function-paren
 
+==> b1206.in <==
+# S1
+
+if (
+   $version ge
+   '2.8.0' )
+{  $cons->run ( {
+'-sequence'
+              => $aln2,
+'-outseq'
+              =>
+              $consoutfile
+      } );
+}
+
+# S2
+
+if (
+   $version ge
+   '2.8.0' )
+{
+   $cons->run ( {
+      '-sequence'
+           => $aln2,
+      '-outseq'
+           =>
+           $consoutfile
+   } );
+}
+
+
+==> b1206.par <==
+--block-brace-vertical-tightness=1
+--continuation-indentation=5
+--nodelete-old-newlines
+--indent-columns=3
+--maximum-line-length=17
+--opening-brace-always-on-right
+--paren-vertical-tightness-closing=1
+--space-function-paren
+--stack-opening-hash-brace
+--weld-nested-containers
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
index f1a70e78214e954ced6a7371b5adfe5aed92b1d8..b95b0a54433536a05b87e4754a279ea8932fcc68 100644 (file)
@@ -8234,6 +8234,22 @@ sub weld_nested_containers {
 
         }
 
+        # RULE: Avoid welding under stress.  The idea is that we need to have a
+        # little space* within a welded container to avoid instability.  Note
+        # that after each weld the level values are reduced, so long multiple
+        # welds can still be made.  This rule will seldom be a limiting factor
+        # in actual working code. Fixes b1206.
+
+        # *the current rule is that we require a space of 'ci' + 'i' + 8,
+        # where 'ci' is the value of n in -ci=n and 'i' is the value in -i=n.
+        my $inner_level = $inner_opening->[_LEVEL_];
+        my $max_len     = $maximum_text_length_at_level[ $inner_level + 1 ];
+        my $excess_inside_space =
+          $max_len -
+          $rOpts_continuation_indentation -
+          $rOpts_indent_columns - 8;
+        if ( $excess_inside_space <= 0 ) { next }
+
         # Set flag saying if this pair starts a new weld
         my $starting_new_weld = !( @welds && $outer_seqno == $welds[-1]->[0] );
 
index 16a02ceadb2149e3cfb052533f51fe93ee785676..4e28fb1d681ba6b0a0403e06c8bd0ac301eec258 100644 (file)
@@ -2,6 +2,14 @@
 
 =over 4
 
+=item B<Fix formatting instability b1206>
+
+Testing with random parameters produced an instability due welding with
+a very short line length and large value of -ci.  This is similar to issues
+b1197-b1204 and fixed with a similar method.
+
+14 Sep 2021.
+
 =item B<Fix unusual parsing error b1205>
 
 Testing with random parameters produced an instability caused by misparsing