From 0e4a77d764b13da623965a6a00a985569511eebb Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 3 Nov 2021 07:30:53 -0700 Subject: [PATCH] Do not break hash braces under stress (fixes b1238) --- dev-bin/run_convergence_tests.pl.data | 22 ++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 8 +++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 907df0f8..90ce7ec1 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7883,6 +7883,28 @@ $obj= {foo => sub { "bar" ; } --space-keyword-paren --variable-maximum-line-length +==> b1238.in <== +# S1 + local $Other::{ ${ \ + "f4" } } = + sub { "h1" }; + +# S2 + local $Other::{ + ${ + \ "f4" + } + } = sub { "h1" }; + +==> b1238.par <== +--continuation-indentation=8 +--delete-old-whitespace +--indent-columns=1 +--line-up-parentheses +--maximum-line-length=26 +--paren-vertical-tightness-closing=1 +--variable-maximum-line-length + ==> b131.in <== unless ( open( SCORE, "+>>$Score_File" ) ) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 36653c4b..be291f54 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -7183,6 +7183,7 @@ sub is_in_block_by_i { # or is at root level # or there is some kind of error (i.e. unbalanced file) # returns false otherwise + return 1 if ( $i < 0 ); # shouldn't happen, bad call my $seqno = $parent_seqno_to_go[$i]; return 1 if ( !$seqno || $seqno eq SEQ_ROOT ); return 1 if ( $self->[_rblock_type_of_seqno_]->{$seqno} ); @@ -17525,8 +17526,13 @@ EOM # Ignore old breakpoints when under stress. # Fixes b1203 b1204 as well as b1197-b1200. - if ( $levels_to_go[$i_opening] >= $stress_level ) { + if ( $saw_opening_structure + && $levels_to_go[$i_opening] >= $stress_level ) + { $cab_flag = 2; + + # Do not break hash braces under stress (fixes b1238) + $do_not_break_apart ||= $types_to_go[$i_opening] eq 'L'; } if ( !$is_long_term -- 2.39.5