]> git.donarmstrong.com Git - perltidy.git/commitdiff
adjust vertical alignment rules when lines end in '=>'
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 9 Dec 2020 14:12:04 +0000 (06:12 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 9 Dec 2020 14:12:04 +0000 (06:12 -0800)
lib/Perl/Tidy/VerticalAligner.pm
local-docs/BugLog.pod

index 52e1cad87b7c3f6dfa1e7866e5ecde88559033b2..ea3d06aacd6200694ee14e4e266707bb23f411be 100644 (file)
@@ -3641,14 +3641,12 @@ sub Dump_tree_groups {
                 $saw_if_or ||= $is_if_or{$raw_tok};
             }
 
-            # Look for a line ending in a bare '=>'
-            # These make marginal matches with just two lines.
-            $line_ending_fat_comma = (
-                     $j == $jmax_1 - 2
-                  && $raw_tok eq '=>'
-                  && ( $rfield_lengths_0->[ $j + 1 ] == 2
-                    || $rfield_lengths_1->[ $j + 1 ] == 2 )
-            );
+           # When the first of the two lines ends in a bare '=>' this will
+           # probably be marginal match.
+            $line_ending_fat_comma =
+                 $j == $jmax_1 - 2
+              && $raw_tok eq '=>'
+              && $rfield_lengths_0->[ $j + 1 ] == 2;
 
             my $pad = $rfield_lengths_1->[$j] - $rfield_lengths_0->[$j];
             if ( $j == 0 ) {
index 81d6b3333be096b172b007216e7fa19eaf2959d9..9f6fd5122be9b3fa98db48b88c601616f157d534 100644 (file)
@@ -2,6 +2,45 @@
 
 =over 4
 
+=item B<Improve vertical alignment of lines ending in fat comma>
+
+A minor adjustment was made to the rule for aligning lines which end in '=>'.
+When there are just two lines in an alignment group, the alignment is avoided
+if the first of the two ends in a '=>'.  Previously, alignment was avoided
+if either ended in a '=>'.  The old rule was preventing some good alignments 
+in a later stage of the iteration.  In the following example, the last
+two lines are processed separately because they do not match the comma
+in 'sprintf'.  The new rule allows the fat comma alignment to eventually
+get made later in the iteration. Update made 9 Dec 2020.
+
+    # OLD 
+    $template->param(
+        classlist => $classlist,
+        ...,
+        suggestion => $suggestion,
+        totspent   => sprintf( "%.2f", $totspent ),
+        totcomtd   => sprintf( "%.2f", $totcomtd ),
+        totavail   => sprintf( "%.2f", $totavail ),
+        nobudget => $#results == -1 ? 1 : 0,
+        intranetcolorstylesheet =>
+          C4::Context->preference("intranetcolorstylesheet"),
+        ...
+    );
+
+    # NEW
+    $template->param(
+        classlist => $classlist,
+        ...,
+        suggestion              => $suggestion,
+        totspent                => sprintf( "%.2f", $totspent ),
+        totcomtd                => sprintf( "%.2f", $totcomtd ),
+        totavail                => sprintf( "%.2f", $totavail ),
+        nobudget                => $#results == -1 ? 1 : 0,
+        intranetcolorstylesheet =>
+          C4::Context->preference("intranetcolorstylesheet"),
+        ...
+    );
+
 =item B<Avoid processing a file more than once>
 
 In the unlikely event that  a user enters a filename more than once on the