From: Steve Hancock Date: Mon, 21 Mar 2022 13:04:47 +0000 (-0700) Subject: fix rare formatting issue b1318 b1322 b1328 X-Git-Tag: 20220217.02^0 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=23eb0d007d0d28ca6ce098b4cea28ef53ec74705;p=perltidy.git fix rare formatting issue b1318 b1322 b1328 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index d8bad6c3..1517ac34 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -9433,6 +9433,22 @@ my %config = ( --maximum-line-length=19 --variable-maximum-line-length +==> b1318.in <== + my $h = $integerValue->copy()->bmod( + '16' + )->bstr(); + + my $h = + $integerValue->copy()->bmod( + '16' + )->bstr(); + +==> b1318.par <== +--extended-line-up-parentheses +--keep-old-breakpoints-before='Q' +--maximum-line-length=61 +--variable-maximum-line-length + ==> b1319.in <== # S1 my @tests = ( @@ -9486,6 +9502,23 @@ my $parser = --indent-columns=0 --maximum-line-length=53 +==> b1322.in <== + my$result + =$self->bus()->connection_settermchar( + $self->connection_handle(),$termchar + ); + + my$result=$self->bus()->connection_settermchar( + $self->connection_handle(),$termchar + ); + +==> b1322.par <== +--noadd-whitespace +--extended-line-up-parentheses +--keep-old-breakpoints-before='i' +--maximum-line-length=53 +--want-break-before='=' + ==> b1324.in <== if ( blessed( @@ -9575,6 +9608,22 @@ WriteMakefile( --keep-old-breakpoints-after='} ) ]' --maximum-line-length=43 +==> b1328.in <== + my $exchange = $self->_channel()->exchange( + name => $self->_fq_name('order'), + ); + + my $exchange + = $self->_channel()->exchange( + name => $self->_fq_name('order'), + ); + +==> b1328.par <== +--extended-line-up-parentheses +--keep-old-breakpoints-after='(' +--variable-maximum-line-length +--want-break-before='=' + ==> b140.in <== $cmd[ $i ]=[ $s, $e, $cmd, \@hunk, $i ] ; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 085cfb24..262cfe0b 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -20956,7 +20956,26 @@ sub get_available_spaces_to_go { # type, see if it would be helpful to 'break' after the '=' to # save space my $last_equals = $last_lp_equals{$total_depth}; - if ( $last_equals && $last_equals > $ii_begin_line ) { + + # Skip an empty set of parens, such as after channel(): + # my $exchange = $self->_channel()->exchange( + # This fixes issues b1318 b1322 b1323 b1328 + # TODO: maybe also skip parens with just one token? + my $is_empty_container; + if ( $last_equals && $ii < $max_index_to_go ) { + my $seqno = $type_sequence_to_go[$ii]; + my $inext_nb = $ii + 1; + $inext_nb++ + if ( $types_to_go[$inext_nb] eq 'b' ); + my $seqno_nb = $type_sequence_to_go[$inext_nb]; + $is_empty_container = + $seqno && $seqno_nb && $seqno_nb == $seqno; + } + + if ( $last_equals + && $last_equals > $ii_begin_line + && !$is_empty_container ) + { my $seqno = $type_sequence_to_go[$ii];