]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fixed bug with -et=8 (entab leading whitespace)
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 12 Nov 2018 23:30:02 +0000 (15:30 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 12 Nov 2018 23:30:02 +0000 (15:30 -0800)
lib/Perl/Tidy/VerticalAligner.pm
local-docs/ChangeLog.pod

index 9c89efd1fd6ef5e399127739346834aad3af343a..4b6f540b1aefad071653f5f16eba069fbeb3b1f1 100644 (file)
@@ -1604,7 +1604,12 @@ sub salvage_equality_matches {
     # return 0 or undef if unsuccessful
     # return 1 if successful
 
-    # We only do this if there is one old line
+    # Here is a very simple example of two lines where we could at least
+    # align the equals:
+    #  $x = $class->_sub( $x, $delta );
+    #  $xpownm1 = $class->_pow( $class->_copy($x), $nm1 );    # x(i)^(n-1)
+
+    # We will only do this if there is one old line (and one new line)
     return unless ($maximum_line_index == 0 );
     return if ($is_matching_terminal_line);
 
@@ -2701,6 +2706,17 @@ sub valign_output_step_D {
 
         # Handle entab option
         elsif ($rOpts_entab_leading_whitespace) {
+
+           # Patch 12-nov-2018 based on report from Glenn. Extra padding was
+           # not correctly entabbed, nor were side comments:
+           # Increase leading space count for a padded line to get correct tabbing
+            if ( $line =~ /^(\s+)(.*)$/ ) {
+                my $spaces = length($1);
+                if ( $spaces > $leading_space_count ) {
+                    $leading_space_count = $spaces;
+                }
+            }
+
             my $space_count =
               $leading_space_count % $rOpts_entab_leading_whitespace;
             my $tab_count =
index 16cb654cb5360def1739168476eb38ecb862bc69..f6e91e184e30273ba757c0af2f445f08d7e7e2e3 100644 (file)
     stamp on certain closing side comments. We need to avoid this in order
     to test this feature in an installation test.
 
+  - Fixed bug with the entab option, -et=8, in which the leading space of
+    some lines was was not entabbed.  This happened in code which was adjusted
+    for vertical alignment and in hanging side comments. Thanks to Glenn.
+
   - Vertical alignment has been improved in several ways.  Thanks especially to
     Glenn for sending helpful snippets.