breaks it may temporarily revert to its default indentation method. This can
occur for example if there are blank lines, block comments, multi-line quotes,
or side comments between the opening and closing parens, braces, or brackets.
+It will also occur if a multi-line anonymous sub occurs within a container
+since that will impose specific line breaks (such as line breaks
+after statements).
In addition, any parameter which significantly restricts the ability of
perltidy to choose newlines will conflict with B<-lp> and will cause
$rdepth_of_opening_seqno = $self->[_rdepth_of_opening_seqno_];
$rblock_type_of_seqno = $self->[_rblock_type_of_seqno_];
+ my $K_closing_container = $self->[_K_closing_container_];
+ my $K_opening_container = $self->[_K_opening_container_];
+
my $file_writer_object = $self->[_file_writer_object_];
my $rbreak_container = $self->[_rbreak_container_];
my $rshort_nested = $self->[_rshort_nested_];
elsif ( $block_type =~ /$ASUB_PATTERN/ ) {
if ($is_one_line_block) {
+
$rbrace_follower = \%is_anon_sub_1_brace_follower;
+
+ # Exceptions to help keep -lp intact, see git #74 ...
+ # Exception 1: followed by '}' on this line
+ if ( $Ktoken_vars < $K_last
+ && $next_nonblank_token eq '}' )
+ {
+ $rbrace_follower = undef;
+ $keep_going = 1;
+ }
+
+ # Exception 2: followed by '}' on next line
+ elsif ( $Ktoken_vars == $K_last ) {
+
+ my $p_seqno = $parent_seqno_to_go[$max_index_to_go];
+ my $Kc = $K_closing_container->{$p_seqno};
+ if ( defined($Kc)
+ && $rLL->[$Kc]->[_TOKEN_] eq '}'
+ && $Kc - $Ktoken_vars <= 2 )
+ {
+ $rbrace_follower = undef;
+ $keep_going = 1;
+
+ # Keep the break if container is fully broken
+ my $Ko = $K_opening_container->{$p_seqno};
+ $self->set_forced_breakpoint($max_index_to_go)
+ if ( $Ko < $K_first );
+ }
+ }
}
else {
$rbrace_follower = \%is_anon_sub_brace_follower;
=over 4
+=item B<Partial fix for issue git #74 on -lp at anonymous subs>
+
+In the following snippet, the final one-line anonymous sub is not followed by a
+comma. This caused the -lp mode to revert to standard indentation mode because
+a forced line break was being made after the closing sub brace:
+
+ # OLD, perltidy -lp
+ $got = timethese(
+ $iterations,
+ {
+ Foo => sub { ++$foo },
+ Bar => '++$bar',
+ Baz => sub { ++$baz }
+ }
+ );
+
+An update was made to check for and fix this.
+
+ # NEW, perltidy -lp
+ $got = timethese(
+ $iterations,
+ {
+ Foo => sub { ++$foo },
+ Bar => '++$bar',
+ Baz => sub { ++$baz }
+ }
+ );
+
+But note that this only applies to one-line anonymous subs. If an anonymous
+sub is broken into several lines due to its length or complexity, then
+these forced line breaks cause indentation to revert to the standard
+indentation scheme.
+
+22 Sep 2021.
+
+
=item B<Fix issues b1209 related to -vmll>
Testing with random parameters produced a formatting instability related to