]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix cuddled else with sort,map,grep
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 4 Jun 2019 00:48:25 +0000 (17:48 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 4 Jun 2019 00:48:25 +0000 (17:48 -0700)
lib/Perl/Tidy/Formatter.pm

index 80b5580f90b02280699b56e37c371b8962208f05..a91ec208eb6fa47c0e8af4a69dacc1e741e8c389 100644 (file)
@@ -8116,8 +8116,15 @@ sub starting_one_line_block {
     if ( $is_sort_map_grep_eval{$block_type} ) {
 
        # Patch for issue git#9: do not try to form new one line blocks for a
-       # cuddled block type. For example, for flags -ce and -cbl='map,sort,grep'
-        if ( !$rcuddled_block_types->{'*'}->{$block_type} ) {
+       # cuddled block type. For example, for flags -ce and
+       # -cbl='map,sort,grep'
+        if (   $rOpts->{'cuddled-else'}
+            && %$rcuddled_block_types
+            && $rcuddled_block_types->{'*'}->{$block_type} )
+        {
+            # this is a cuddled type
+        }
+        else {
             create_one_line_block( $i_start, 1 );
         }
     }