From afe84a80ed08f03e634f8bcc731f30fc3819cf32 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Mon, 12 Nov 2018 15:30:02 -0800 Subject: [PATCH] Fixed bug with -et=8 (entab leading whitespace) --- lib/Perl/Tidy/VerticalAligner.pm | 18 +++++++++++++++++- local-docs/ChangeLog.pod | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 9c89efd1..4b6f540b 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -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 = diff --git a/local-docs/ChangeLog.pod b/local-docs/ChangeLog.pod index 16cb654c..f6e91e18 100644 --- a/local-docs/ChangeLog.pod +++ b/local-docs/ChangeLog.pod @@ -50,6 +50,10 @@ 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. -- 2.39.5