From 1ac2d7dd732288f497710276c46f8985ddac69bb Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 3 Sep 2020 18:03:56 -0700 Subject: [PATCH] fix problem with combo -scbb and -csc; lost data --- lib/Perl/Tidy/Formatter.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 9bf538ef..dc11a18e 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -10806,7 +10806,7 @@ sub send_lines_to_vertical_aligner { my $rvertical_tightness_flags = $self->set_vertical_tightness_flags( $n, $n_last_line, $ibeg, $iend, - $ri_first, $ri_last, $ending_in_quote ); + $ri_first, $ri_last, $ending_in_quote, $closing_side_comment ); # flush an outdented line to avoid any unwanted vertical alignment $self->flush_vertical_aligner() if ($is_outdented_line); @@ -12297,7 +12297,7 @@ sub K_mate_index { sub set_vertical_tightness_flags { my ( $self, $n, $n_last_line, $ibeg, $iend, $ri_first, $ri_last, - $ending_in_quote ) + $ending_in_quote, $closing_side_comment ) = @_; # Define vertical tightness controls for the nth line of a batch. @@ -12551,11 +12551,16 @@ sub set_vertical_tightness_flags { # Vertical Tightness Flags Section 3: # Handle type 4, a closing block brace on the last line of the batch Check # for a last line with isolated closing BLOCK curly + # Patch: added a check for any new closing side comment which the + # -csc option may generate. If it exists, there will be a side comment + # so we cannot combine with a brace on the next line. This issue + # occurs for the combination -scbb and -csc is used. #-------------------------------------------------------------- elsif ($rOpts_stack_closing_block_brace && $ibeg eq $iend && $block_type_to_go[$iend] - && $types_to_go[$iend] eq '}' ) + && $types_to_go[$iend] eq '}' + && ( !$closing_side_comment || $n < $n_last_line ) ) { my $spaces = $rOpts_block_brace_tightness == 2 ? 0 : 1; @{$rvertical_tightness_flags} = -- 2.39.5