From fd744d2fa5a379f7c592cc57c743e66cc2471078 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 16 Jan 2022 18:11:02 -0800 Subject: [PATCH] fix issue b1310 --- dev-bin/run_convergence_tests.pl.data | 32 +++++++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 25 +++++++++++++-------- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 26f2c9c1..ccd676fe 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -9241,6 +9241,38 @@ else --maximum-line-length=46 --weld-nested-containers +==> b1310.in <== +isnt( + exception { + $meta = + Moose::Meta::Class->create_anon_class( + superclasses => ['t::bugs::Bar',], # any old class will work + roles => ['Role::BreakOnLoad',], ) + }, + undef, + 'Class dies when attempting composition' +); + +isnt( + exception { + $meta = + Moose::Meta::Class->create_anon_class( + superclasses => ['t::bugs::Bar',] + , # any old class will work + roles => ['Role::BreakOnLoad',], + ) + }, + undef, + 'Class dies when attempting composition' +); + + +==> b1310.par <== +--extended-line-up-parentheses +--maximum-line-length=71 +--square-bracket-tightness=2 +--variable-maximum-line-length + ==> b140.in <== $cmd[ $i ]=[ $s, $e, $cmd, \@hunk, $i ] ; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 7716021e..19392a31 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1509,6 +1509,20 @@ EOM } } + #------------------------------------------------------------------- + # The combination -xlp and -vmll can be unstable unless -iscl is set + #------------------------------------------------------------------- + # This is a temporary fix for issue b1302. See also b1306, b1310. + # FIXME: look for a better fix. + if ( $rOpts->{'variable-maximum-line-length'} + && $rOpts->{'extended-line-up-parentheses'} + && !$rOpts->{'ignore-side-comment-lengths'} ) + { + $rOpts->{'ignore-side-comment-lengths'} = 1; + + # we could write a warning here + } + #----------------------------------------------------------- # The combination -lp -vmll can be unstable if -ci<2 (b1267) #----------------------------------------------------------- @@ -10719,15 +10733,8 @@ sub collapsed_lengths { { my $Kend = $K_terminal; - # Ignore comment length if -vmll. Some rare instabilities have - # been found involving side comments and -vmll. So side comment - # lengths are ignored in this loop if -vmll is set for now. - # (They are still checked elsewhere). This could cause - # occasional excess line lengths, but -vmll use is rare and - # that is preferable to instability. Fixes b1302 and b1306. - if ( $has_comment - && !$rOpts_ignore_side_comment_lengths - && !$rOpts_variable_maximum_line_length ) + if ( $has_comment + && !$rOpts_ignore_side_comment_lengths ) { $Kend = $K_last; } -- 2.39.5