]> git.donarmstrong.com Git - perltidy.git/commitdiff
Do not break hash braces under stress (fixes b1238)
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 3 Nov 2021 14:30:53 +0000 (07:30 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 3 Nov 2021 14:30:53 +0000 (07:30 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 907df0f820dc90841cd371cc892d3817e9528e66..90ce7ec1413fb2e86e1c39f69f37fceaf32166ab 100644 (file)
@@ -7883,6 +7883,28 @@ $obj= {foo => sub { "bar" ; }
 --space-keyword-paren
 --variable-maximum-line-length
 
+==> b1238.in <==
+# S1
+  local $Other::{ ${ \
+            "f4" } } =
+          sub { "h1" };
+
+# S2
+  local $Other::{
+   ${
+    \ "f4"
+   }
+  } = sub { "h1" };
+
+==> b1238.par <==
+--continuation-indentation=8
+--delete-old-whitespace
+--indent-columns=1
+--line-up-parentheses
+--maximum-line-length=26
+--paren-vertical-tightness-closing=1
+--variable-maximum-line-length
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
index 36653c4be3c9cef9d94e41477808506e9056a170..be291f54b5c0da0aecf120b188c940d07323f4e1 100644 (file)
@@ -7183,6 +7183,7 @@ sub is_in_block_by_i {
     #     or is at root level
     #     or there is some kind of error (i.e. unbalanced file)
     # returns false otherwise
+    return 1 if ( $i < 0 );  # shouldn't happen, bad call
     my $seqno = $parent_seqno_to_go[$i];
     return 1 if ( !$seqno || $seqno eq SEQ_ROOT );
     return 1 if ( $self->[_rblock_type_of_seqno_]->{$seqno} );
@@ -17525,8 +17526,13 @@ EOM
 
                 # Ignore old breakpoints when under stress.
                 # Fixes b1203 b1204 as well as b1197-b1200.
-                if ( $levels_to_go[$i_opening] >= $stress_level ) {
+                if (   $saw_opening_structure
+                    && $levels_to_go[$i_opening] >= $stress_level )
+                {
                     $cab_flag = 2;
+
+                    # Do not break hash braces under stress (fixes b1238)
+                    $do_not_break_apart ||= $types_to_go[$i_opening] eq 'L';
                 }
 
                 if (  !$is_long_term