# Sixth Approximation. Welds.
#---------------------------------------------------------------
- # Do not allow a break within welds,
+ # Do not allow a break within welds
if ( $seqno && $total_weld_count ) {
if ( $self->weld_len_right( $seqno, $type ) ) {
$strength = NO_BREAK;
# ^--K_o_o ^--K_i_o
# @array) )
my $Kn_first = $K_outer_opening;
+ my $Kn_last_nonblank;
for (
my $Kn = $K_outer_opening + 1 ;
$Kn <= $K_inner_opening ;
next if ( $rLL->[$Kn]->[_TYPE_] eq 'b' );
if ( !$nonblank_count ) { $Kn_first = $Kn }
if ( $Kn eq $K_inner_opening ) { $nonblank_count++; last; }
+ $Kn_last_nonblank = $Kn;
# skip chain of identifier tokens
my $last_type = $type;
last if ( $nonblank_count > 2 );
}
+ # Patch for b1104: do not weld to a paren preceded by sort/map/grep
+ # because the special line break rules may cause a blinking state
+ if ( defined($Kn_last_nonblank)
+ && $rLL->[$K_inner_opening]->[_TOKEN_] eq '('
+ && $rLL->[$Kn_last_nonblank]->[_TYPE_] eq 'k' )
+ {
+ my $token = $rLL->[$Kn_last_nonblank]->[_TOKEN_];
+
+ # Turn off welding at sort/map/grep (
+ if ( $is_sort_map_grep{$token} ) { $nonblank_count = 10 }
+ }
+
if (
# adjacent opening containers, like: do {{
} ## end package Perl::Tidy::Formatter
1;
-
=over 4
+=item B<Avoid welding at sort/map/grep paren calls>
+
+Random testing produced several cases of unstable welds in which the inner
+container something like 'sort ('. The problem was that there are special
+rules which prevent a break following such a paren. The problem was fixed by
+preventing welds at these locations.
+
+This update fixes cases b1077 b1092 b1093 b1094 b1104 b1105 b1108.
+
+17 Apr 2021.
+
=item B<Fix issue git#62>
This fixes issue git #62. A similar issue for the % operator was fixed.