# line length and gets broken in a bad spot.
my $length_tol = 1;
+ # Sometimes the total starting indentation can increase at a later stage,
+ # for example the -bli command will move an opening brace inward one level
+ # instead of one ci. To avoid blinkers, we add an extra length tolerance.
+ $length_tol +=
+ abs( $rOpts_indent_columns - $rOpts_continuation_indentation );
+
my $excess_length_to_K = sub {
my ($K) = @_;
my $Kouter_closing = $K_closing_container->{$outer_seqno};
my $Kinner_closing = $K_closing_container->{$inner_seqno};
+ # RULE: do not weld if inner container has <= 3 tokens unless the next
+ # token is a heredoc (so we know there will be multiple lines)
+ if ( $Kinner_closing - $Kinner_opening <= 4 ) {
+ my $Knext_nonblank = $self->K_next_nonblank($Kinner_opening);
+ next unless defined($Knext_nonblank);
+ my $type = $rLL->[$Knext_nonblank]->[_TYPE_];
+ next unless ( $type eq 'h' );
+ }
+
my $outer_opening = $rLL->[$Kouter_opening];
my $inner_opening = $rLL->[$Kinner_opening];
my $outer_closing = $rLL->[$Kouter_closing];
# (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.
- if ( $iline_oo == $iline_oc && $excess_length_to_K->($Klast) <= 0 )
+ # For stability, we remove the length tolerance which has been added
+ if ( $iline_oo == $iline_oc
+ && $excess_length_to_K->($Klast) <= $length_tol )
{
$is_one_line_weld = 1;
}
my $min_req = 2;
# But for -boc we want to see a break at an interior list comma to be
- # sure the list stays broken. It is sufficient to require at least two
+ # sure the list stays broken. It is sufficient to require at least two
# non-blank lines within the block.
if ($rOpts_break_at_old_comma_breakpoints) {
my $iline = $rLL->[$KK]->[_LINE_INDEX_];
=over 4
+=item B<adjust line length and token count tolerances for -wn>
+
+Most remaining edge cases of blinking states involving the -wn parameter have
+been fixed by adjusting some tolerances in sub weld_nested_containers. The
+following cases are fixed with this update:
+
+b156 b157 b186 b196 b454 b520 b527 b530 b532 b533 b534 b612 b614 b625 b627
+
+This update has no effect for realistic parameter settings.
+
+30 Jan 2021.
+
=item B<fix additional edge blinker cases involving -wn>
Some blinking cases produced in random testing were traced to welding in
b002 b003 b005 b006 b007 b009 b010 b014 b015 b017 b020 b111 b112 b113 b124 b126
b128 b151 b153 b439 b606
-29 Jan 2021.
+29 Jan 2021, 33f1f2b.
=item B<fix additional edge blinker cases involving -wn>
b025 b075 b091 b109 b110 b152 b154 b155 b162 b168 b176 b422 b423 b424 b425 b426
b565
-29 Jan 2021.
+29 Jan 2021, 33f1f2b.
=item B<fix some edge blinker cases involving -wn>
b131 b134 b136 b205 b233 b238 b284 b350 b352 b358 b385 b487 b604 b605
-29 Jan 2021.
+29 Jan 2021, 33f1f2b.
=item B<fix some edge blinker cases involving -bbxi=n esp. with -boc>
)
);
- # do not weld to a one-line block because the function could get separated
- # from its opening paren
+ # OLD: do not weld to a one-line block because the function could
+ # get separated from its opening paren.
+ # NEW: (30-jan-2021): keep one-line block together for stability
$_[0]->code_handler(
sub { $morexxxxxxxxxxxxxxxxxx .= $_[1] . ":" . $_[0] . "\n" } );
@{ $coords[0] }, @{ $coords[1] }
) ) );
- # do not weld to a one-line block because the function could get separated
- # from its opening paren
- $_[0]->code_handler(
- sub { $morexxxxxxxxxxxxxxxxxx .= $_[1] . ":" . $_[0] . "\n" } );
+ # OLD: do not weld to a one-line block because the function could
+ # get separated from its opening paren.
+ # NEW: (30-jan-2021): keep one-line block together for stability
+ $_[0]->code_handler
+ ( sub { $morexxxxxxxxxxxxxxxxxx .= $_[1] . ":" . $_[0] . "\n" } );
# another example; do not weld because the sub is not broken
$wrapped->add_around_modifier(
_("Cannot delete zone $name: sub-zones or appellations exist.")
);
- # fixed RULE 1: this is now a stable state with -wn
+ # OLD: fixed RULE 1: this is now a stable state with -wn
+ # NEW (30 jan 2021): do not weld if one interior token
$app->FORM->{'appbar1'}->set_status(
_("Cannot delete zone $name: sub-zones or appellations exist.")
);
_("Cannot delete zone $name: sub-zones or appellations exist.")
);
- # fixed RULE 1: this is now a stable state with -wn
- $app->FORM->{'appbar1'}->set_status( _(
- "Cannot delete zone $name: sub-zones or appellations exist.") );
+ # OLD: fixed RULE 1: this is now a stable state with -wn
+ # NEW (30 jan 2021): do not weld if one interior token
+ $app->FORM->{'appbar1'}->set_status(
+ _("Cannot delete zone $name: sub-zones or appellations exist.")
+ );
my $compass = uc( opposite_direction( line_to_canvas_direction(
@{ $coords[0] }, @{ $coords[1] } ) ) );
- # do not weld to a one-line block because the function could get separated
- # from its opening paren
+ # OLD: do not weld to a one-line block because the function could
+ # get separated from its opening paren.
+ # NEW: (30-jan-2021): keep one-line block together for stability
$_[0]->code_handler
( sub { $morexxxxxxxxxxxxxxxxxx .= $_[1] . ":" . $_[0] . "\n" } );
_("Cannot delete zone $name: sub-zones or appellations exist.")
);
- # fixed RULE 1: this is now a stable state with -wn
+ # OLD: fixed RULE 1: this is now a stable state with -wn
+ # NEW (30 jan 2021): do not weld if one interior token
$app->FORM->{'appbar1'}->set_status(_(
"Cannot delete zone $name: sub-zones or appellations exist."));
my $compass = uc( opposite_direction( line_to_canvas_direction(
@{ $coords[0] }, @{ $coords[1] } ) ) );
- # do not weld to a one-line block because the function could get separated
- # from its opening paren
+ # OLD: do not weld to a one-line block because the function could
+ # get separated from its opening paren.
+ # NEW: (30-jan-2021): keep one-line block together for stability
$_[0]->code_handler
( sub { $morexxxxxxxxxxxxxxxxxx .= $_[1] . ":" . $_[0] . "\n" } );
)
);
- # do not weld to a one-line block because the function could get separated
- # from its opening paren
+ # OLD: do not weld to a one-line block because the function could
+ # get separated from its opening paren.
+ # NEW: (30-jan-2021): keep one-line block together for stability
$_[0]->code_handler(
sub { $morexxxxxxxxxxxxxxxxxx .= $_[1] . ":" . $_[0] . "\n" } );
@{ $coords[0] }, @{ $coords[1] }
) ) );
- # do not weld to a one-line block because the function could get separated
- # from its opening paren
- $_[0]->code_handler(
- sub { $morexxxxxxxxxxxxxxxxxx .= $_[1] . ":" . $_[0] . "\n" } );
+ # OLD: do not weld to a one-line block because the function could
+ # get separated from its opening paren.
+ # NEW: (30-jan-2021): keep one-line block together for stability
+ $_[0]->code_handler
+ ( sub { $morexxxxxxxxxxxxxxxxxx .= $_[1] . ":" . $_[0] . "\n" } );
# another example; do not weld because the sub is not broken
$wrapped->add_around_modifier(
_("Cannot delete zone $name: sub-zones or appellations exist.")
);
- # fixed RULE 1: this is now a stable state with -wn
+ # OLD: fixed RULE 1: this is now a stable state with -wn
+ # NEW (30 jan 2021): do not weld if one interior token
$app->FORM->{'appbar1'}->set_status(_(
"Cannot delete zone $name: sub-zones or appellations exist."));
----------
_("Cannot delete zone $name: sub-zones or appellations exist.")
);
- # fixed RULE 1: this is now a stable state with -wn
+ # OLD: fixed RULE 1: this is now a stable state with -wn
+ # NEW (30 jan 2021): do not weld if one interior token
$app->FORM->{'appbar1'}->set_status(
_("Cannot delete zone $name: sub-zones or appellations exist.")
);
_("Cannot delete zone $name: sub-zones or appellations exist.")
);
- # fixed RULE 1: this is now a stable state with -wn
- $app->FORM->{'appbar1'}->set_status( _(
- "Cannot delete zone $name: sub-zones or appellations exist.") );
+ # OLD: fixed RULE 1: this is now a stable state with -wn
+ # NEW (30 jan 2021): do not weld if one interior token
+ $app->FORM->{'appbar1'}->set_status(
+ _("Cannot delete zone $name: sub-zones or appellations exist.")
+ );
#3...........
},