]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1428
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 23 Nov 2022 16:37:40 +0000 (08:37 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 23 Nov 2022 16:37:40 +0000 (08:37 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index c5b5a1714dd9cddc56e0202208f429fc603eb7f9..1ec73c9b0a55dc5da1d3de1a0eecf63253073347 100644 (file)
@@ -10988,6 +10988,26 @@ my$sem=sub
 --variable-maximum-line-length
 --want-trailing-commas='m'
 
+==> b1428.in <==
+         is(
+              grep ( { $_->{branchcode} eq 'MYLIBRARY' and $_->{selected} == 1 }
+                      @$libraries ),
+              1,
+              'Without selected parameter, my library should be preselected',
+         );
+
+         is(
+                  grep (
+                           {              $_->{branchcode} eq 'MYLIBRARY'
+                                      and $_->{selected} == 1 } @$libraries ),
+                  1,
+'Without selected parameter, my library should be preselected',
+         );
+
+==> b1428.par <==
+--extended-line-up-parentheses
+--indent-columns=9
+
 ==> b1430.in <==
          $t->post_ok(
                   "//$auth_userid:$password@/api/v1/advanced_editor/macros" =>
index ad9352511a37896c4e3575a2cd93c3d8d1042631..55e4a9a77b9921449aae8651b178b0d3db1989cb 100644 (file)
@@ -11925,6 +11925,35 @@ BEGIN {
     };
 }
 
+sub is_fragile_block_type {
+    my ( $self, $block_type, $seqno ) = @_;
+
+    # Given:
+    #  $block_type = the block type of a token, and
+    #  $seqno      = its sequence number
+
+    # Return:
+    #  true if this block type stays broken after being broken,
+    #  false otherwise
+
+    # This sub has been added to isolate a tricky decision needed
+    # to fix issue b1428.
+
+    # The coding here needs to agree with:
+    # - sub process_line where variable '$rbrace_follower' is set
+    # - sub process_line_inner_loop where variable '$is_opening_BLOCK' is set,
+
+    if (   $is_sort_map_grep_eval{$block_type}
+        || $block_type eq 't'
+        || $self->[_rshort_nested_]->{$seqno} )
+    {
+        return 0;
+    }
+
+    return 1;
+
+} ## end sub is_fragile_block_type
+
 sub xlp_collapsed_lengths {
 
     my $self = shift;
@@ -12385,9 +12414,11 @@ EOM
                             && $block_length <
                             $maximum_line_length_at_level[$level]
 
-                            # But skip this for sort/map/grep/eval blocks
-                            # because they can reform (b1345)
-                            && !$is_sort_map_grep_eval{$block_type}
+                            # But skip this for blocks types which can reform,
+                            # like sort/map/grep/eval blocks, to avoid
+                            # instability (b1345, b1428)
+                            && $self->is_fragile_block_type( $block_type,
+                                $seqno )
                           )
                         {
                             $collapsed_len = $block_length;