From ca0ddf4a9a38c7ec1803655f51810ba74dfb0ad1 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 9 Dec 2020 06:12:04 -0800 Subject: [PATCH] adjust vertical alignment rules when lines end in '=>' --- lib/Perl/Tidy/VerticalAligner.pm | 14 +++++------- local-docs/BugLog.pod | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 52e1cad8..ea3d06aa 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -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 ) { diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 81d6b333..9f6fd512 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,45 @@ =over 4 +=item B + +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 In the unlikely event that a user enters a filename more than once on the -- 2.39.5