%is_closing_sequence_token,
%is_container_label_type,
+ @all_operators,
+
# Initialized in check_options. These are constants and could
# just as well be initialized in a BEGIN block.
%is_do_follower,
@q = qw(&& || and or : ? . + - * /);
@is_chain_operator{@q} = (1) x scalar(@q);
+ # Operators that the user can request break before or after.
+ # Note that some are keywords
+ @all_operators = qw(% + - * / x != == >= <= =~ !~ < > | &
+ = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=
+ . : ? && || and or err xor
+ );
+
# We can remove semicolons after blocks preceded by these keywords
@q =
qw(BEGIN END CHECK INIT AUTOLOAD DESTROY UNITCHECK continue if elsif else
}
# implement user break preferences
- my @all_operators = qw(% + - * / x != == >= <= =~ !~ < > | &
- = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=
- . : ? && || and or err xor
- );
-
my $break_after = sub {
my @toks = @_;
foreach my $tok (@toks) {
my %break_before_or_after_token;
BEGIN {
- my @q = qw( = . : ? and or xor && || );
+
+ # Updated to use all operators. This fixes case b1054
+ # Here is the previous simplified version:
+ ## my @q = qw( . : ? and or xor && || );
+ my @q = @all_operators;
+
push @q, ',';
@break_before_or_after_token{@q} = (1) x scalar(@q);
}
return if ( $self->weld_len_right_to_go($i) );
my $token = $tokens_to_go[$i];
+ my $type = $types_to_go[$i];
# For certain tokens, use user settings to decide if we break before or
# after it
- # qw( = . : ? and or xor && || )
- if ( $break_before_or_after_token{$token} ) {
+ if ( $break_before_or_after_token{$token}
+ && ( $type eq $token || $type eq 'k' ) )
+ {
if ( $want_break_before{$token} && $i >= 0 ) { $i-- }
}
# breaks are forced before 'if' and 'unless'
- elsif ( $is_if_unless{$token} ) { $i-- }
+ elsif ( $is_if_unless{$token} && $type eq 'k' ) { $i-- }
if ( $i >= 0 && $i <= $max_index_to_go ) {
my $i_nonblank = ( $types_to_go[$i] ne 'b' ) ? $i : $i - 1;
=over 4
+=item B<Follow user requests better to break before operators>
+
+Random testing produced some cases in which user requests to break before selected
+operators were not being followed. For example
+
+ # OLD: perltidy -wbb='.='
+ $value .=
+ ( grep /\s/, ( $value, $next ) )
+ ? " $next"
+ : $next;
+
+ # FIXED: perltidy -wbb='.='
+ $value
+ .= ( grep /\s/, ( $value, $next ) )
+ ? " $next"
+ : $next;
+
+This fixes case b1054.
+
+28 Mar 2021.
+
=item B<Fix problems with combinations of -iob -lp>
This is an correction to the update of 13 Mar 2021, 71adc77. Random testing
and these new cases: b1034 b1048 b1049 b1050 b1056 b1058
-27 Mar 2021
+27 Mar 2021, cc94623.
=item B<Add flag -lpxl=s to provide control over -lp formatting>