]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix rare formatting issue b1325
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 20 Mar 2022 20:13:08 +0000 (13:13 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 20 Mar 2022 20:13:08 +0000 (13:13 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 6dfdeffa2592ff7fe43fd878326c60847d987929..cef8fa0cde8358cd3b67fd4d0d90788326296592 100644 (file)
@@ -9486,6 +9486,37 @@ my $parser =
 --indent-columns=0
 --maximum-line-length=53
 
+==> b1325.in <==
+WriteMakefile(
+   PREREQ_PM    => {
+           'Tk'            =>'800.025',
+           'Tk::DiffText'  => 0,
+           'Perl::Tidy'    => 0, # comes in the perltidy application
+           'Log::Log4perl' => '1.0',
+           'version'       => 0, # used to detect old Tk's and use different widgets where required
+   },
+);
+
+WriteMakefile(
+   PREREQ_PM    => {
+      'Tk'            =>
+            '800.025',
+      'Tk::DiffText'  => 0,
+      'Perl::Tidy'    => 0, # comes in the perltidy application
+      'Log::Log4perl' => '1.0',
+      'version'       => 0, # used to detect old Tk's and use different widgets where required
+   },
+);
+
+==> b1325.par <==
+--noadd-whitespace
+--continuation-indentation=6
+--extended-continuation-indentation
+--extended-line-up-parentheses
+--indent-columns=3
+--maximum-line-length=33
+--variable-maximum-line-length
+
 ==> b1327.in <==
  @where=
    $self->_where()->where_clause(
index f73a4508b9c87942c4cd128025e85aac110ccb27..bf690481a07865f0e02751ef4863967056fdcea8 100644 (file)
@@ -1512,20 +1512,6 @@ EOM
         }
     }
 
-    #-------------------------------------------------------------------
-    # The combination -xlp and -vmll can be unstable unless -iscl is set
-    #-------------------------------------------------------------------
-    # This is a temporary fix for issue b1310. FIXME: look for a better fix.
-    # No longer needed for b1302, b1306.
-    if (   $rOpts->{'variable-maximum-line-length'}
-        && $rOpts->{'extended-line-up-parentheses'}
-        && !$rOpts->{'ignore-side-comment-lengths'} )
-    {
-        $rOpts->{'ignore-side-comment-lengths'} = 1;
-
-        # we could write a warning here
-    }
-
     #-----------------------------------------------------------
     # The combination -lp -vmll can be unstable if -ci<2 (b1267)
     #-----------------------------------------------------------
@@ -10807,6 +10793,7 @@ sub collapsed_lengths {
     my $ris_permanently_broken     = $self->[_ris_permanently_broken_];
     my $ris_list_by_seqno          = $self->[_ris_list_by_seqno_];
     my $rhas_broken_list           = $self->[_rhas_broken_list_];
+    my $rtype_count_by_seqno       = $self->[_rtype_count_by_seqno_];
 
     my $K_start_multiline_qw;
     my $level_start_multiline_qw = 0;
@@ -11017,6 +11004,18 @@ sub collapsed_lengths {
                     #    stabilize by itself after one or two iterations.
                     #  - So, not doing this for now
 
+                    # Turn off the interrupted list rule if -vmll is set and a
+                    # list has '=>' characters.  This avoids instabilities due
+                    # to dependence on old line breaks; issue b1325.
+                    if (   $interrupted_list_rule
+                        && $rOpts_variable_maximum_line_length )
+                    {
+                        my $rtype_count = $rtype_count_by_seqno->{$seqno};
+                        if ( $rtype_count && $rtype_count->{'=>'} ) {
+                            $interrupted_list_rule = 0;
+                        }
+                    }
+
                     # Include length to a comma ending this line
                     if (   $interrupted_list_rule
                         && $rLL->[$K_terminal]->[_TYPE_] eq ',' )