return $digest;
};
+sub get_iteration_count {
+ return $rstatus->{iteration_count};
+}
+
BEGIN {
# Array index names for $self.
$add_option->( 'delete-weld-interfering-commas', 'dwic', '!' );
$add_option->( 'delete-semicolons', 'dsm', '!' );
$add_option->( 'function-paren-vertical-alignment', 'fpva', '!' );
+ $add_option->( 'iterate-trailing-commas', 'itc', '!' );
$add_option->( 'keyword-paren-inner-tightness', 'kpit', '=i' );
$add_option->( 'keyword-paren-inner-tightness-list', 'kpitl', '=s' );
$add_option->( 'logical-padding', 'lop', '!' );
indent-columns=4
integer-range-check=2
interbracket-arrow-complexity=1
+ iterate-trailing-commas
iterations=1
keep-old-blank-lines=1
keyword-paren-inner-tightness=1
return;
} ## end sub setup_convergence_test
+sub not_converged {
+ my $self = shift;
+
+ # Block convergence of this iteration. This is currently needed
+ # when adding/deleting commas is delayed by 1 iteration (see git #156)
+ $self->[_K_arrival_order_matches_] = 0;
+ return;
+} ## end sub not_converged
+
sub get_convergence_check {
my ($self) = @_;
my $rlist = $self->[_rK_checklist_];
return;
} ## end sub add_phantom_semicolon
+sub delay_trailing_comma_op {
+ my $self = shift;
+
+ # Returns:
+ # true if a trailing comma operation should be skipped
+ # false otherwise
+
+ # This can prevent unwanted path-dependent formatting when both
+ # line breaks are changing and we are only adding or deleting
+ # commas, but not both. See git #156
+
+ # permission must be given
+ return if ( !$rOpts->{'iterate-trailing-commas'} );
+
+ # we must be at the first of multiple iterations
+ my $it = Perl::Tidy::get_iteration_count();
+ my $max_iterations = $rOpts->{'iterations'};
+ if ( $it == 1 && $max_iterations > 1 ) {
+
+ # if so, force another iteration
+ my $file_writer_object = $self->[_file_writer_object_];
+ $file_writer_object->not_converged();
+ return 1;
+ }
+ return;
+} ## end sub delay_trailing_comma_op
+
sub add_trailing_comma {
# Implement the --add-trailing-commas flag to the line end before index $KK:
}
}
- # if so, add a comma
- if ($match) {
+ # If so, and not delayed, add a comma
+ if ( $match && !$self->delay_trailing_comma_op() ) {
# any blank after the comma will be added before the closing paren,
# below
}
}
- # If no match, delete it
- if ( !$match ) {
+ # If no match and not delayed
+ if ( !$match && !$self->delay_trailing_comma_op() ) {
+ # delete it
return $self->unstore_last_nonblank_token(',');
}
return;
}
- #-----------------------------------------------------------------------
- # Loop over all sub calls to compare counts of args passed with expected
- #-----------------------------------------------------------------------
+ #--------------------------------------------------------------
+ # Loop over all sub calls to compare call and return arg counts
+ #--------------------------------------------------------------
foreach my $seqno ( keys %{$rsub_call_paren_info_by_seqno} ) {
my $rcall_item = $rsub_call_paren_info_by_seqno->{$seqno};