- A warning will no longer be given if a script has an opening code-skipping
comment '#<<V' which is not terminated with a closing comment '#>>V'. This
- makes code-skipping and format-skipping behave in a similar way: a
- '#>>V' or '#>>>' comment without a corresponding closing comment will cause
+ makes code-skipping and format-skipping behave in a similar way: an
+ opening comment without a corresponding closing comment will cause
the rest of a file to be skipped. If there is a question about which lines
are skipped, a .LOG file can be produced with the -g flag and it will have
this information.
This limit had been placed to avoid some formatting instabilities,
but recent coding improvements allow the limit to be removed.
+ - The -wn and -bbxx=n flags were not working together correctly. This has
+ been fixed.
+
- Numerous minor fixes have been made. A complete list is at:
https://github.com/perltidy/perltidy/blob/master/local-docs/BugLog.pod
This utility runs perltidy on a database of stability test cases.
It can:
- - run perttidy on the stability test cases
+ - run perltidy on the stability test cases
- do maintenance of the database of test cases
There are four options: run [DEFAULT], pack, merge, unpack ( -r -p -m -u )
--line-up-parentheses
--maximum-line-length=27
+==> b1173.in <==
+# problem caused by -wn and -bbhbi not working together
+
+# S1
+ my $two =
+ $CLASS
+ ->new(
+ facet_data =>
+ { hubs => [ {
+ details =>
+"DO NOT SHOW"
+ } ],
+ }
+ );
+
+# S2
+
+ my $two =
+ $CLASS
+ ->new(
+ facet_data =>
+ { hubs =>
+ [
+ { details =>
+"DO NOT SHOW"
+ }
+ ],
+ }
+ );
+
+==> b1173.par <==
+--break-before-hash-brace-and-indent=1
+--break-before-hash-brace=2
+--break-before-square-bracket=2
+--continuation-indentation=5
+--indent-columns=3
+--maximum-line-length=16
+--variable-maximum-line-length
+--vertical-tightness=2
+--weld-nested-containers
+
==> b120.in <==
# Same as bug96
# State 1
<dl>
+<dt id="Fix-to-make--wn-and--bbxx-n-flags-work-together"><b>Fix to make -wn and -bbxx=n flags work together</b></dt>
+<dd>
+
+<p>Testing with random parameters produced some cases where the combination of -wn and various -bbxx=n flags were not working together. To illustrate, consider the following script (-sil=1 just means start at 1 indentation level)</p>
+
+<pre><code> # perltidy -sil=1
+ $$d{"day_name"} = [
+ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ]
+ ];</code></pre>
+
+<p>With welding we get:</p>
+
+<pre><code> # -sil=1 -wn
+ $$d{"day_name"} = [ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ] ];</code></pre>
+
+<p>With -bbsb=3 (--break-before-square-brackets) we get:</p>
+
+<pre><code> # -sil=1 -bbsb=3
+ $$d{"day_name"} =
+ [
+ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ]
+ ];</code></pre>
+
+<p>So far, so good. But for the combination -bbsb=3 -wn we get</p>
+
+<pre><code> # OLD: ERROR
+ # -sil=1 -bbsb=3 -wn
+ $$d{"day_name"} = [ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ] ];</code></pre>
+
+<p>which is incorrect because it ignors the -bbsb flag. The corrected result is</p>
+
+<pre><code> # NEW: OK
+ # -sil=1 -bbsb=3 -wn
+ $$d{"day_name"} =
+ [ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ] ];</code></pre>
+
+<p>This update fixes case b1173. It works for any number of welded containers, and the -bbxxi=n flags also work correctly.</p>
+
+<p>16 Jul 2021.</p>
+
+</dd>
<dt id="Fix-problem-with-side-comment-after-pattern"><b>Fix problem with side comment after pattern</b></dt>
<dd>
- A warning will no longer be given if a script has an opening code-skipping
comment '#<<V' which is not terminated with a closing comment '#>>V'. This
- makes code-skipping and format-skipping behave in a similar way: a
- '#>>V' or '#>>>' comment without a corresponding closing comment will cause
+ makes code-skipping and format-skipping behave in a similar way: an
+ opening comment without a corresponding closing comment will cause
the rest of a file to be skipped. If there is a question about which lines
are skipped, a .LOG file can be produced with the -g flag and it will have
this information.
This limit had been placed to avoid some formatting instabilities,
but recent coding improvements allow the limit to be removed.
+- The -wn and -bbxx=n flags were not working together correctly. This has
+ been fixed.
+
- Numerous minor fixes have been made. A complete list is at:
https://github.com/perltidy/perltidy/blob/master/local-docs/BugLog.pod
}
# Update the end index and lengths of any long welds to extend to the far
- # end. We only need to do this for the right links, not for the left links.
- # This has to be processed in sorted order.
+ # end. This has to be processed in sorted order.
+ # Left links added for b1173.
my $Kend = -1;
foreach my $Kstart ( sort { $a <=> $b } @K_multi_weld ) {
my @Klist;
push @Klist, $Kstart;
$Kend = $rK_weld_right->{$Kstart};
+ $rK_weld_left->{$Kend} = $Kstart;
my $Knext = $rK_weld_right->{$Kend};
while ( defined($Knext) ) {
push @Klist, $Kend;
- $Kend = $Knext;
- $Knext = $rK_weld_right->{$Kend};
+ $Kend = $Knext;
+ $rK_weld_left->{$Kend} = $Kstart;
+ $Knext = $rK_weld_right->{$Kend};
}
pop @Klist; # values for last entry are already correct
foreach my $KK (@Klist) {
my $rtype_count_by_seqno = $self->[_rtype_count_by_seqno_];
my $rlec_count_by_seqno = $self->[_rlec_count_by_seqno_];
my $rno_xci_by_seqno = $self->[_rno_xci_by_seqno_];
+ my $rK_weld_right = $self->[_rK_weld_right_];
my $length_tol =
max( 1, $rOpts_continuation_indentation, $rOpts_indent_columns );
# a depth of just 1
my $is_list = $self->is_list_by_seqno($seqno);
my $has_list = $rhas_list->{$seqno};
+
+ # Fix for b1173: if welded opening container, use flag of innermost
+ # seqno. Otherwise, the restriction $has_list==1 prevents triple and
+ # higher welds from following the -BBX parameters.
+ if ($total_weld_count) {
+ my $KK_test = $rK_weld_right->{$KK};
+ if ( defined($KK_test) ) {
+ my $seqno_inner = $rLL->[$KK_test]->[_TYPE_SEQUENCE_];
+ $is_list ||= $self->is_list_by_seqno($seqno_inner);
+ $has_list = $rhas_list->{$seqno_inner};
+ }
+ }
+
next unless ( $is_list || $has_list && $has_list == 1 );
my $has_broken_list = $rhas_broken_list->{$seqno};
my $Kl = $K_to_go[$il];
my $Kr = $K_to_go[$ir];
my $Kend = $Kr;
- my $iend = $ir;
my $type_end = $rLL->[$Kr]->[_TYPE_];
# Backup before any side comment
$Kend = $self->K_previous_nonblank($Kr);
next unless defined($Kend);
$type_end = $rLL->[$Kend]->[_TYPE_];
- $iend = $ir + ( $Kend - $Kr );
}
+
+ # Backup to the start of any weld; fix for b1173.
+ if ($total_weld_count) {
+ my $Kend_test = $rK_weld_left->{$Kend};
+ if ( defined($Kend_test) && $Kend_test > $Kl ) {
+ $Kend = $Kend_test;
+ $Kend_test = $rK_weld_left->{$Kend};
+ }
+
+ # Do not break if we did not back up to the start of a weld
+ # (shouldn't happen)
+ next if ( defined($Kend_test) );
+ }
+
my $token = $rLL->[$Kend]->[_TOKEN_];
next unless ( $is_opening_token{$token} );
next unless ( $Kl < $Kend - 1 );
# Use the flag which was previously set
next unless ( $rbreak_before_container_by_seqno->{$seqno} );
- # But never break a weld
- next if ( $total_weld_count && defined( $rK_weld_left->{$Kend} ) );
-
# Install a break before this opening token.
my $Kbreak = $self->K_previous_nonblank($Kend);
my $ibreak = $Kbreak - $Kl + $il;
# Honor any flag to reduce -ci set by the -bbxi=n option
if ( $seqno_beg && $rwant_reduced_ci->{$seqno_beg} ) {
- # if this is an opening, it must be alone on the line
- if ( $is_closing_type{$type_beg} || $ibeg == $iend ) {
+ # if this is an opening, it must be alone on the line ...
+ if ( $is_closing_type{$type_beg} || $ibeg == $i_terminal ) {
$adjust_indentation = 1;
}
- elsif ( $iend <= $ibeg + 2 ) {
- my $inext = $inext_to_go[$ibeg];
- if ( $inext
- && ( $inext > $iend || $types_to_go[$inext] eq '#' ) )
- {
- $adjust_indentation = 1;
+
+ # ... or a single welded unit (fix for b1173)
+ elsif ($total_weld_count) {
+ my $Kterm = $K_to_go[$i_terminal];
+ my $Kterm_test = $rK_weld_left->{$Kterm};
+ if ( defined($Kterm_test) && $Kterm_test >= $K_beg ) {
+ $Kterm = $Kterm_test;
}
+ if ( $Kterm == $K_beg ) { $adjust_indentation = 1 }
}
}
=over 4
+=item B<Fix to make -wn and -bbxx=n flags work together>
+
+Testing with random parameters produced some cases where the combination of -wn
+and various -bbxx=n flags were not working together. To illustrate, consider
+the following script (-sil=1 just means start at 1 indentation level)
+
+ # perltidy -sil=1
+ $$d{"day_name"} = [
+ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ]
+ ];
+
+With welding we get:
+
+ # -sil=1 -wn
+ $$d{"day_name"} = [ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ] ];
+
+With -bbsb=3 (--break-before-square-brackets) we get:
+
+ # -sil=1 -bbsb=3
+ $$d{"day_name"} =
+ [
+ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ]
+ ];
+
+So far, so good. But for the combination -bbsb=3 -wn we get
+
+ # OLD: ERROR
+ # -sil=1 -bbsb=3 -wn
+ $$d{"day_name"} = [ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ] ];
+
+which is incorrect because it ignors the -bbsb flag. The corrected result is
+
+ # NEW: OK
+ # -sil=1 -bbsb=3 -wn
+ $$d{"day_name"} =
+ [ [
+ "lundi", "mardi", "mercredi", "jeudi",
+ "vendredi", "samedi", "dimanche"
+ ] ];
+
+This update fixes case b1173. It works for any number of welded containers,
+and the -bbxxi=n flags also work correctly.
+
+16 Jul 2021.
+
=item B<Fix problem with side comment after pattern>
Testing with randomly placed side comments produced an error illustrated