my $rtype_count = $self->[_rtype_count_by_seqno_]->{$type_sequence};
my $comma_count = 0;
my $fat_comma_count = 0;
- my $comma_count_inner = 0;
+ my $has_inner_list;
if ($rtype_count) {
$comma_count = $rtype_count->{','};
# containers must be nesting on the right
return unless ($is_nesting_right);
+ # if outer container type is paren, must be sub call
+ my $token = $rLL_new->[$K_opening]->[_TOKEN_];
+ if ( $token eq '(' ) {
+ my $Km = $self->K_previous_nonblank( $K_opening, $rLL_new );
+ my $type_p = defined($Km) ? $rLL_new->[$Km]->[_TYPE_] : 'b';
+ ## see also sub count_return_values_wanted
+ my $is_function_call =
+ $type_p eq 'U'
+ || $type_p eq 'i'
+ || $type_p eq 'w'
+ || $type_p eq '->';
+ return unless ($is_function_call);
+ }
+
# inner container must have commas
my $rtype_count_pp = $self->[_rtype_count_by_seqno_]->{$seqno_pp};
return unless ($rtype_count_pp);
- $comma_count_inner = $rtype_count_pp->{','};
-## my $fat_comma_count_inner = $rtype_count_pp->{'=>'};
- return if ( !$comma_count_inner );
- return if ( $comma_count_inner < 2 );
+ $has_inner_list =
+ ( $rtype_count_pp->{','} || $rtype_count_pp->{'=>'} )
+ && !$rtype_count_pp->{';'};
+ return unless ($has_inner_list);
# and inner container must be multiline
$iline_first = $self->[_rfirst_comma_line_index_]->{$seqno_pp};
my $Ktest = $self->K_next_nonblank( $K_opening, $rLL_new );
return unless ($Ktest);
my $seqno_test = $rLL_new->[$Ktest]->[_TYPE_SEQUENCE_];
- if ( !$seqno_test || $seqno_test != $seqno_pp ) {
- return;
+
+ # allow 1 nonblank token between opening tokens
+ if ( !$seqno_test ) {
+ $Ktest = $self->K_next_nonblank( $Ktest, $rLL_new );
+ return unless ($Ktest);
+ $seqno_test = $rLL_new->[$Ktest]->[_TYPE_SEQUENCE_];
}
- # if outer container type is paren, must be sub call
- my $token = $rLL_new->[$K_opening]->[_TOKEN_];
- if ( $token eq '(' ) {
- my $Km = $self->K_previous_nonblank( $K_opening, $rLL_new );
- my $type_p = defined($Km) ? $rLL_new->[$Km]->[_TYPE_] : 'b';
- ## see also sub count_return_values_wanted
- my $is_function_call =
- $type_p eq 'U'
- || $type_p eq 'i'
- || $type_p eq 'w'
- || $type_p eq '->';
- return unless ($is_function_call);
+ if ( !$seqno_test || $seqno_test != $seqno_pp ) {
+ return;
}
}
}
# To avoid instability in edge cases, when adding commas we uses the
# multiline_commas definition, but when deleting we use multiline
# containers. This fixes b1384, b1396, b1397, b1398, b1400.
+ # Added fat_comma_count to handle one-line with key=>value, git143
my $is_multiline =
- $if_add ? $has_multiline_commas : $has_multiline_containers;
+ $if_add
+ ? $has_multiline_commas || $has_multiline_containers && $fat_comma_count
+ : $has_multiline_containers;
my $is_bare_multiline_comma = $is_multiline && $KK == $Kfirst;
# 'm' matches a Multiline list
#-----------------------------
elsif ( $trailing_comma_style eq 'm' ) {
- $match = $is_multiline && ( $comma_count || $comma_count_inner );
+ $match = $is_multiline && ( $comma_count || $has_inner_list );
}
#----------------------------------