From: Steve Hancock Date: Tue, 5 Jan 2021 15:10:15 +0000 (-0800) Subject: update comments X-Git-Tag: 20210111~12 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=59e4d18e9dd1677abc2461f1e0c9abe6c4f83742;p=perltidy.git update comments --- diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 318f1391..e1db520d 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -4220,12 +4220,29 @@ sub is_good_side_comment_column { # RULE2: Forget a side comment after a short line difference, # where 'short line difference' is computed from a formula. + # Using a smooth formula helps minimize sudden large changes. my $line_diff = $line_number - $self->[_last_side_comment_line_number_]; my $alev_diff = abs( $level - $self->[_last_side_comment_level_] ); - # TAIL-WAG-DOG factor + # '$num5' is the number of comments in the first 5 lines after the first + # comment. It is needed to keep a compact group of side comments from + # being influenced by a more distant side comment. $num5 = 1 unless ($num5); + # Some values: + + # $adiff $num5 $short_diff + # 0 * 12 + # 1 1 6 + # 1 2 4 + # 1 3 3 + # 1 4 2 + # 2 1 4 + # 2 2 2 + # 2 3 1 + # 3 1 3 + # 3 2 1 + my $short_diff = SC_LONG_LINE_DIFF / ( 1 + $alev_diff * $num5 ); goto FORGET