my $rOpts_break_at_old_method_breakpoints =
$rOpts->{'break-at-old-method-breakpoints'};
+ my $rOpts_ignore_side_comment_lengths =
+ $rOpts->{'ignore-side-comment-lengths'};
+
# This array will hold the sequence numbers of the tokens to be welded.
my @welds;
return ($excess_length);
};
+ my $excess_length_of_line = sub {
+ my ( $Kfirst, $Klast ) = @_;
+ my $length_before_Kfirst =
+ $Kfirst <= 0
+ ? 0
+ : $rLL->[ $Kfirst - 1 ]->[_CUMULATIVE_LENGTH_];
+ my $level = $rLL->[$Kfirst]->[_LEVEL_];
+ my $ci_level = $rLL->[$Kfirst]->[_CI_LEVEL_];
+ my $indent = $rOpts_indent_columns * $level +
+ $ci_level * $rOpts_continuation_indentation;
+ if ($rOpts_variable_maximum_line_length) {
+ $indent -= $level * $rOpts_indent_columns;
+ }
+
+ my $Kend = $Klast;
+ if ( $rOpts_ignore_side_comment_lengths
+ && $rLL->[$Klast]->[_TYPE_] eq '#' )
+ {
+ my $Kprev = $self->K_previous_nonblank($Klast);
+ if ( defined($Kprev) && $Kprev >= $Kfirst ) { $Kend = $Kprev }
+ }
+
+ my $length =
+ $rLL->[$Kend]->[_CUMULATIVE_LENGTH_] - $length_before_Kfirst;
+ my $excess_length = $indent + $length - $rOpts_maximum_line_length;
+ return ($excess_length);
+ };
+
my $length_to_opening_seqno = sub {
my ($seqno) = @_;
my $KK = $K_opening_container->{$seqno};
}
}
- # Revised -vmll treatment to fix cases b866 b1074 b1075 b1084 b1086
- # b1087 b1088
+ # Revised -vmll treatment to fix cases b866 b1074 b1075 b1084 b1086
+ # b1087 b1088
if ($rOpts_variable_maximum_line_length) {
$starting_indent -= $level * $rOpts_indent_columns;
}
# (1) the containers are all on one line, and
# (2) the line does not exceed the allowable length, and
# This flag is used to avoid creating blinkers.
- # For stability, we remove the length tolerance which has been added
+ # Changed 'excess_length_to_K' to 'excess_length_of_line'
+ # to get exact lengths and fix b604 b605.
if ( $iline_oo == $iline_oc
- && $excess_length_to_K->($Klast) <= 0 )
+ && $excess_length_of_line->( $Kfirst, $Klast ) <= 0 )
{
$is_one_line_weld = 1;
}
} ## end package Perl::Tidy::Formatter
1;
+
=over 4
+=item B<Slight change in weld length calculation>
+
+Random testing produced some cases of instability with some unusual input
+parameter combinations involving the -wn parameter. This was fixed by revising
+a line length calculation. This fixes cases b604 and b605.
+
+9 Apr 2021.
+
=item B<Improve treatment of -vmll with -wn>
Random testing showed a weakness in the treatment of the -vmll flag
This fixes cases b866 b1074 b1075 b1084 b1086 b1087 b1088
-8 Apr 2021.
+8 Apr 2021, a6effa3.
=item B<Merge weld rule 6 into rule 3>