From 4ecc078255e9e921a5850ea3de82de40e7eed48d Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 21 Jul 2021 19:54:55 -0700 Subject: [PATCH] Fix conflict of -bom and -scp parameters --- dev-bin/run_convergence_tests.pl.data | 24 +++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 9 ++++++-- local-docs/BugLog.pod | 33 ++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index a731b171..f8a4a54e 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -6667,6 +6667,30 @@ my $plugin = Koha::FrameworkPlugin->new( { --maximum-line-length=55 --weld-nested-containers +==> b1179.in <== +# -bom and -scp were interfering +# S1 + $resource = { + id => $package->new_from_mana( + $result->{data} + )->id + }; + +# S2 + $resource = { id => $package->new_from_mana( + $result->{data} )->id }; + +# Stable + $resource = { id => $package->new_from_mana( + $result->{data} + )->id }; + +==> b1179.par <== +--break-at-old-method-breakpoints +--indent-columns=8 +--maximum-line-length=60 +--stack-closing-paren + ==> b120.in <== # Same as bug96 # State 1 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index f648a53e..1baf45ed 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -21768,6 +21768,8 @@ sub set_vertical_tightness_flags { # See case b499 for an example. return $rvertical_tightness_flags if ($rOpts_freeze_whitespace); + my $rwant_container_open = $self->[_rwant_container_open_]; + # Uses these parameters: # $rOpts_block_brace_tightness # $rOpts_block_brace_vertical_tightness @@ -21967,9 +21969,12 @@ sub set_vertical_tightness_flags { if ( $is_closing_token{$token_end} && $is_closing_token{$token_beg_next} ) { + + # avoid instability of combo -bom and -sct; b1179 + my $seq_next = $type_sequence_to_go[$ibeg_next]; $stackable = $stack_closing_token{$token_beg_next} - unless ( $block_type_to_go[$ibeg_next] ) - ; # shouldn't happen; just checking + unless ( $block_type_to_go[$ibeg_next] + || $seq_next && $rwant_container_open->{$seq_next} ); } elsif ($is_opening_token{$token_end} && $is_opening_token{$token_beg_next} ) diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index a4245604..dee3c30c 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,37 @@ =over 4 +=item B + +Automated testing with random parameters produced a case of instability caused +by a conflict of parameters -bom and -scp. In the following script the -bom +command says to keep the tokens ')->' on a new line, whereas the -scp command +says to stack the closing paren on the previous line. + + $resource = { + id => $package->new_from_mana( + $result->{data} + )->id + }; + +The parameters are: + + --break-at-old-method-breakpoints + --indent-columns=8 + --maximum-line-length=60 + --stack-closing-paren + +This caused an instability which was fixed by giving priority to the -bom flag. +The stable state is then + + $resource = { id => $package->new_from_mana( + $result->{data} + )->id }; + +This fixes case b1179. + +21 Jul 2021. + =item B This update fixes two problems involving the -kgb option. @@ -68,7 +99,7 @@ to go after the closing brace but a line count was off. This has been fixed: This fixes issue c048. -19 Jul 2021. +19 Jul 2021, 071a3f6. =item B -- 2.39.5