]> git.donarmstrong.com Git - perltidy.git/commitdiff
merge two weld cutoff limits, fixes b1252
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 12 Nov 2021 23:34:27 +0000 (15:34 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 12 Nov 2021 23:34:27 +0000 (15:34 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 4407e908bc868ead43a6854940e72d4f811f951c..9141fa4c72c5e5494490fc8ca1bb18bcc9b5fd8d 100644 (file)
@@ -8154,6 +8154,44 @@ WriteMakefile(
 --line-up-parentheses
 --maximum-line-length=35
 
+==> b1252.in <==
+# S1
+@pack=
+        ([
+"ufunc.pd",
+    Ufunc,
+    PDL::Ufunc
+        ]);
+# S2
+@pack=([
+"ufunc.pd",
+        Ufunc,
+        PDL::Ufunc
+    ]);
+
+==> b1252.par <==
+--noadd-whitespace
+--break-before-all-operators
+--break-before-paren=3
+--continuation-indentation=8
+--delete-old-whitespace
+--maximum-line-length=10
+--opening-paren-right
+--stack-closing-block-brace
+--stack-closing-hash-brace
+--stack-closing-paren
+--stack-closing-square-bracket
+--stack-opening-hash-brace
+--stack-opening-paren
+--stack-opening-square-bracket
+--tight-secret-operators
+--trim-pod
+--novalign-code
+--variable-maximum-line-length
+--vertical-tightness-closing=1
+--vertical-tightness=0
+--weld-nested-containers
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
index 8514480ed9dd28ac6f11ed2ab30d448abcea5c79..793e2b996aac47caf80037fa52fed36265ceb94d 100644 (file)
@@ -8346,6 +8346,27 @@ sub weld_nested_containers {
     my $multiline_tol = $single_line_tol + 1 +
       max( $rOpts_indent_columns, $rOpts_continuation_indentation );
 
+    # Define a welding cutoff level: do not start a weld if the inside
+    # container level equals or exceeds this level.  We use the minimum of two
+    # criteria, either of which may be more restrictive.
+    # Start with a value based on the global stress (cases b1206, b1243):
+    # Note that this has a minimum cutoff level of 3.
+    my $weld_cutoff_level = $stress_level + 3;
+
+    # But use an alternative criterion if more restrictive (cases b1206, b1252)
+    # This allows the cutoff level to go down to 0 in extreme cases.
+    foreach my $level_test ( 0 .. $weld_cutoff_level ) {
+        my $max_len = $maximum_text_length_at_level[ $level_test + 1 ];
+        my $excess_inside_space =
+          $max_len -
+          $rOpts_continuation_indentation -
+          $rOpts_indent_columns - 8;
+        if ( $excess_inside_space <= 0 ) {
+            $weld_cutoff_level = $level_test;
+            last;
+        }
+    }
+
     my $length_to_opening_seqno = sub {
         my ($seqno) = @_;
         my $KK      = $K_opening_container->{$seqno};
@@ -8428,7 +8449,7 @@ sub weld_nested_containers {
         # welds can still be made.  This rule will seldom be a limiting factor
         # in actual working code. Fixes b1206, b1243.
         my $inner_level = $inner_opening->[_LEVEL_];
-        if ( $inner_level > $stress_level + 2 ) { next }
+        if ( $inner_level >= $weld_cutoff_level ) { next }
 
         # Set flag saying if this pair starts a new weld
         my $starting_new_weld = !( @welds && $outer_seqno == $welds[-1]->[0] );