]> git.donarmstrong.com Git - perltidy.git/commitdiff
adjust a -wn rule; this eliminates the last known blinker
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 8 Apr 2020 00:58:04 +0000 (17:58 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 8 Apr 2020 00:58:04 +0000 (17:58 -0700)
lib/Perl/Tidy/Formatter.pm
t/snippets/expect/wn8.def
t/snippets/expect/wn8.wn
t/snippets/packing_list.txt
t/snippets/wn8.in
t/snippets17.t

index 663514fe2476210fbedf2ce0244930eb2a504833..e3daad1fcaea3e1128b446fe0664498d0247bc38 100644 (file)
@@ -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
index c31a77b04882412e3cfe17a7e8fcd5893099b449..98b4d186ed77bd04541f64999958b9074fcc9a00 100644 (file)
@@ -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.")
             );
index 00a672abbaffba8236085f6385593b54bba56551..921d5ec5989de004ba3182dadac39b2dfd3916ba 100644 (file)
@@ -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.") );
index e0bc4d482baf1f51b178c676f8848c82ab9a1e5a..5989765fb17bf67c1395aa13e02addd870cec4d3 100644 (file)
 ../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
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets17.t        bos.bos
-../snippets17.t        bos.def
index 9cce74870938b1206eed2d0af524de753d1e788a..3e07557f23b840be7c110c787e18dab29b0a198e 100644 (file)
@@ -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."));
index 3daa35ccc55b2956f30a6d70ff78a336d8910a89..fb5a36f211e3e0184b45c1579029e43b7dc9d50c 100644 (file)
@@ -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...........
         },