From: Steve Hancock Date: Wed, 8 Apr 2020 00:58:04 +0000 (-0700) Subject: adjust a -wn rule; this eliminates the last known blinker X-Git-Tag: 20200619~97 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=52fe93ef7cabfafb0191d94ad5ef41ba891b5f01;p=perltidy.git adjust a -wn rule; this eliminates the last known blinker --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 663514fe..e3daad1f 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -4080,6 +4080,7 @@ sub weld_nested_containers { my $iline_oo = $outer_opening->[_LINE_INDEX_]; my $iline_io = $inner_opening->[_LINE_INDEX_]; + my $iline_ic = $inner_closing->[_LINE_INDEX_]; # Set flag saying if this pair starts a new weld my $starting_new_weld = !( @welds && $outer_seqno == $welds[-1]->[0] ); @@ -4125,10 +4126,21 @@ sub weld_nested_containers { # would become a blinker without this rule: # $Self->_Add( $SortOrderDisplay{ $Field # ->GenerateFieldForSelectSQL() } ); + # But it is okay to weld a two-line statement if it looks like + # it was already welded, meaning that the two opening containers are + # on a different line that the two closing containers. This is + # necessary to prevent blinking of something like this with + # perltidy -wn -pbp (starting indentation two levels deep): + + # $top_label->set_text( gettext( + # "Unable to create personal directory - check permissions.") ); my $iline_oc = $outer_closing->[_LINE_INDEX_]; my $token_oo = $outer_opening->[_TOKEN_]; - if ( $iline_oc <= $iline_oo + 1 && $token_oo eq '(') { + if ( $iline_oc <= $iline_oo + 1 + && $iline_io == $iline_ic + && $token_oo eq '(' ) + { # Look for following semicolon... my $Knext_nonblank = $self->K_next_nonblank($Kouter_closing); @@ -4148,8 +4160,6 @@ sub weld_nested_containers { } } - my $iline_ic = $inner_closing->[_LINE_INDEX_]; - # DO-NOT-WELD RULE 2: # Do not weld an opening paren to an inner one line brace block # We will just use old line numbers for this test and require diff --git a/t/snippets/expect/wn8.def b/t/snippets/expect/wn8.def index c31a77b0..98b4d186 100644 --- a/t/snippets/expect/wn8.def +++ b/t/snippets/expect/wn8.def @@ -9,11 +9,13 @@ { $die_on_fetch, 0 } }; - # fixed RULE 2 applies to any inner opening token + # fixed RULE 2 applies to any inner opening token; this is a stable + # state with -wn $app->FORM->{'appbar1'}->set_status( _("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.") ); diff --git a/t/snippets/expect/wn8.wn b/t/snippets/expect/wn8.wn index 00a672ab..921d5ec5 100644 --- a/t/snippets/expect/wn8.wn +++ b/t/snippets/expect/wn8.wn @@ -5,11 +5,12 @@ my $res = eval { { $die_on_fetch, 0 } }; - # fixed RULE 2 applies to any inner opening token + # fixed RULE 2 applies to any inner opening token; this is a stable + # state with -wn $app->FORM->{'appbar1'}->set_status( _("Cannot delete zone $name: sub-zones or appellations exist.") ); - $app->FORM->{'appbar1'}->set_status( - _("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.") ); diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index e0bc4d48..5989765f 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -166,6 +166,8 @@ ../snippets17.t wn8.wn ../snippets17.t pbp6.def ../snippets17.t pbp6.pbp +../snippets17.t bos.bos +../snippets17.t bos.def ../snippets2.t angle.def ../snippets2.t arrows1.def ../snippets2.t arrows2.def @@ -326,5 +328,3 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets17.t bos.bos -../snippets17.t bos.def diff --git a/t/snippets/wn8.in b/t/snippets/wn8.in index 9cce7487..3e07557f 100644 --- a/t/snippets/wn8.in +++ b/t/snippets/wn8.in @@ -7,10 +7,12 @@ { $die_on_fetch, 0 } }; - # fixed RULE 2 applies to any inner opening token + # fixed RULE 2 applies to any inner opening token; this is a stable + # state with -wn $app->FORM->{'appbar1'}->set_status( _("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.")); diff --git a/t/snippets17.t b/t/snippets17.t index 3daa35cc..fb5a36f2 100644 --- a/t/snippets17.t +++ b/t/snippets17.t @@ -136,11 +136,13 @@ my $subref = sub ( $cat, $id = do { state $auto_id = 0; $auto_id++ } ) { { $die_on_fetch, 0 } }; - # fixed RULE 2 applies to any inner opening token + # fixed RULE 2 applies to any inner opening token; this is a stable + # state with -wn $app->FORM->{'appbar1'}->set_status( _("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.")); ---------- @@ -308,11 +310,13 @@ sub foo_subroutine_in_main { { $die_on_fetch, 0 } }; - # fixed RULE 2 applies to any inner opening token + # fixed RULE 2 applies to any inner opening token; this is a stable + # state with -wn $app->FORM->{'appbar1'}->set_status( _("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.") ); @@ -330,14 +334,15 @@ sub foo_subroutine_in_main { my $res = eval { { $die_on_fetch, 0 } }; - # fixed RULE 2 applies to any inner opening token + # fixed RULE 2 applies to any inner opening token; this is a stable + # state with -wn $app->FORM->{'appbar1'}->set_status( _("Cannot delete zone $name: sub-zones or appellations exist.") ); - $app->FORM->{'appbar1'}->set_status( - _("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.") ); #9........... },