# Perltidy Change Log
+## 2021 xx xx
+
+ - Added a new option for closing paren placement, -vtc=3, requested in rt #136417.
+
+ - A more complete list of updates is at
+
+ https://github.com/perltidy/perltidy/blob/master/local-docs/BugLog.pod
+
## 2021 04 02
- This release fixes several non-critical bugs which have been found since the last
by a semicolon or another closing token, and is not in
a list environment.
-vtc=2 never break before a closing token.
+ -vtc=3 Like -vtc=1 except always break before a closing token
+ if the corresponding opening token follows an = or =>.
-The rules for B<-vtc=1> are designed to maintain a reasonable balance
-between tightness and readability in complex lists.
+The rules for B<-vtc=1> and B<-vtc=3> are designed to maintain a reasonable
+balance between tightness and readability in complex lists.
=item *
three => 'III',
four => 'IV', );
+ # perltidy -vtc=3
+ my_function(
+ one => 'I',
+ two => 'II',
+ three => 'III',
+ four => 'IV', );
+
+ # perltidy -vtc=3
+ %romanNumerals = (
+ one => 'I',
+ two => 'II',
+ three => 'III',
+ four => 'IV',
+ );
+
+In the last example for B<-vtc=3>, the opening paren is preceded by an equals
+so the closing paren is placed on a new line.
+
The difference between B<-vt=1> and B<-vt=2> is shown here:
# perltidy -lp -vt=1
_rbreak_before_container_by_seqno_ => $i++,
_ris_essential_old_breakpoint_ => $i++,
_roverride_cab3_ => $i++,
+ _ris_assigned_structure_ => $i++,
};
# Array index names for _this_batch_ (in above list)
$self->[_rbreak_before_container_by_seqno_] = {};
$self->[_ris_essential_old_breakpoint_] = {};
$self->[_roverride_cab3_] = {};
+ $self->[_ris_assigned_structure_] = {};
# This flag will be updated later by a call to get_save_logfile()
$self->[_save_logfile_] = defined($logger_object);
my $rparent_of_seqno = {};
my $rchildren_of_seqno = {};
my $roverride_cab3 = {};
+ my $ris_assigned_structure = {};
my $last_nonblank_type = ';';
my $last_nonblank_token = ';';
if ($type_sequence) {
if ( $is_opening_token{$token} ) {
+
+ if ( $last_nonblank_type eq '='
+ || $last_nonblank_type eq '=>' )
+ {
+ $ris_assigned_structure->{$type_sequence} =
+ $last_nonblank_type;
+ }
+
my $seqno_parent = $seqno_stack{ $depth_next - 1 };
$seqno_parent = SEQ_ROOT unless defined($seqno_parent);
push @{ $rchildren_of_seqno->{$seqno_parent} },
$self->[_rchildren_of_seqno_] = $rchildren_of_seqno;
$self->[_ris_list_by_seqno_] = $ris_list_by_seqno;
$self->[_roverride_cab3_] = $roverride_cab3;
+ $self->[_ris_assigned_structure_] = $ris_assigned_structure;
# DEBUG OPTION: make sure the new array looks okay.
# This is no longer needed but should be retained for future development.
{
my $ovt = $opening_vertical_tightness{$token_next};
my $cvt = $closing_vertical_tightness{$token_next};
+
+ # Implement cvt=3: like cvt=0 for assigned structures, like cvt=1
+ # otherwise. Added for rt136417.
+ if ( $cvt == 3 ) {
+ my $seqno = $type_sequence_to_go[$ibeg_next];
+ $cvt = $self->[_ris_assigned_structure_]->{$seqno} ? 0 : 1;
+ }
+
if (
# Never append a trailing line like ')->pack(' because it
=over 4
+=item B<Add option -pvtc=3, requested in rt136416>
+
+A new integer option, n=3, has been added to the vertical tightness closing flags.
+For a container with n=3, the closing token will behave as for n=0 if the opening
+token is preceded by an '=' or '=>', and like n=1 otherwise.
+
+3 May 2021.
+
=item B<Fix vertical alignment issue in rt136416>
This update fixes a problem with unwanted vertical alignment rasied in
--- /dev/null
+function(
+ #
+ a, b, c
+);
+
+%hash = (
+ a => b,
+ c => d,
+);
--- /dev/null
+function(
+ #
+ a, b, c );
+
+%hash = (
+ a => b,
+ c => d,
+);
../snippets24.t lpxl.lpxl4
../snippets24.t lpxl.lpxl5
../snippets24.t git63.def
+../snippets24.t align35.def
../snippets3.t ce_wn1.ce_wn
../snippets3.t ce_wn1.def
../snippets3.t colin.colin
../snippets9.t rt98902.def
../snippets9.t rt98902.rt98902
../snippets9.t rt99961.def
-../snippets24.t align35.def
+../snippets24.t rt136417.def
+../snippets24.t rt136417.rt136417
--- /dev/null
+function(
+ #
+ a, b, c);
+
+%hash = (
+ a => b,
+ c => d,
+);
#10 lpxl.lpxl5
#11 git63.def
#12 align35.def
+#13 rt136417.def
+#14 rt136417.rt136417
# To locate test #13 you can search for its name or the string '#13'
'lpxl5' => <<'----------',
-lp -lpxl='{ [ F(2'
----------
+ 'rt136417' => "-vtc=3",
};
############################
dog => {prowl => "growl", pool => "drool"},
mouse => {nibble => "kibble"},
};
+----------
+
+ 'rt136417' => <<'----------',
+function(
+ #
+ a, b, c);
+
+%hash = (
+ a => b,
+ c => d,
+);
----------
};
use constant COUNTDOWN => scalar reverse 1, 2, 3, 4, 5;
#12...........
},
+
+ 'rt136417.def' => {
+ source => "rt136417",
+ params => "def",
+ expect => <<'#13...........',
+function(
+ #
+ a, b, c
+);
+
+%hash = (
+ a => b,
+ c => d,
+);
+#13...........
+ },
+
+ 'rt136417.rt136417' => {
+ source => "rt136417",
+ params => "rt136417",
+ expect => <<'#14...........',
+function(
+ #
+ a, b, c );
+
+%hash = (
+ a => b,
+ c => d,
+);
+#14...........
+ },
};
my $ntests = 0 + keys %{$rtests};