--paren-vertical-tightness=1
--weld-nested-containers
+==> b1189.in <==
+#S1
+if ($ON_EBCDIC)
+{
+ delete @Encode::ExtModule{ qw(euc-cn gb2312 gb12345 gbk cp936 iso-ir-165 MacChineseSimp
+ euc-jp iso-2022-jp 7bit-jis shiftjis MacJapanese cp932
+ euc-kr ksc5601 cp949 MacKorean
+ big5 big5-hkscs cp950 MacChineseTrad
+ gb18030 big5plus euc-tw)
+ };
+}
+
+#S2
+if ($ON_EBCDIC)
+{ delete @Encode::ExtModule{
+ qw(euc-cn gb2312 gb12345 gbk cp936 iso-ir-165 MacChineseSimp
+ euc-jp iso-2022-jp 7bit-jis shiftjis MacJapanese cp932
+ euc-kr ksc5601 cp949 MacKorean
+ big5 big5-hkscs cp950 MacChineseTrad
+ gb18030 big5plus euc-tw)
+ };
+}
+
+==> b1189.par <==
+--block-brace-vertical-tightness=1
+--continuation-indentation=7
+--nodelete-old-newlines
+--maximum-line-length=99
+--notrim-qw
+--weld-nested-containers
+
==> b120.in <==
# Same as bug96
# State 1
my $is_old_weld =
( $iline_oo == $iline_io && $iline_ic == $iline_oc );
+ # Fix for case b1189. If quote is marked as type 'Q' then only weld
+ # if the two closing tokens are on the same input line. Otherwise,
+ # the closing line will be output earlier in the pipeline than
+ # other CODE lines and welding will not actually occur. This will
+ # leave a half-welded structure with potential formatting
+ # instability. This might be fixed by adding a check for a weld on
+ # a closing Q token and sending it down the normal channel, but it
+ # would complicate the code and is potentially risky.
+ next
+ if (!$is_old_weld
+ && $next_type eq 'Q'
+ && $iline_ic != $iline_oc );
+
# If welded, the line must not exceed allowed line length
( my $ok_to_weld, $maximum_text_length, $starting_lentot, my $msg )
= $self->setup_new_weld_measurements( $Kouter_opening,
=over 4
+=item B<Fix edge case of formatting instability, b1189>.
+
+Testing with random parameters produced a case of unstable formatting involving
+welding with parameter -notrim-qw. The problem was that the -notrim-qw flag
+converts a qw quote into a quote with fixed leading whitespace.
+The lines of these types of quotes which have no other code are are output early
+in the formatting process, since they have a fixed format, so welding does not work.
+In particular, the closing tokens cannot be welded if they are on a separate line.
+This also holds for all types of non-qw quotes. So welding can only be done
+if the first and last lines of a non-qw quote contain other code. A check for
+this was added.
+
+For example, in the following snippet the terminal '}' is alone on a line:
+
+ is eval(q{
+ $[ = 3;
+ BEGIN { my $x = "foo\x{666}"; $x =~ /foo\p{Alnum}/; }
+ $t[3];
+ }
+ ), "a";
+
+# In the previous version this was half-welded:
+# OLD: perltidy -wn -sil=0
+
+ is eval( q{
+ $[ = 3;
+ BEGIN { my $x = "foo\x{666}"; $x =~ /foo\p{Alnum}/; }
+ $t[3];
+ }
+ ),
+ "a";
+
+The new check avoids welding in this case, giving
+
+ # NEW: perltidy -wn -sil=0
+ is eval(
+ q{
+ $[ = 3;
+ BEGIN { my $x = "foo\x{666}"; $x =~ /foo\p{Alnum}/; }
+ $t[3];
+ }
+ ),
+ "a";
+
+Welding can still be done if the opening and closing container tokens
+have other code. For example, welding can be done for the following snippet:
+
+ is eval(q{
+ $[ = 3;
+ BEGIN { my $x = "foo\x{666}"; $x =~ /foo\p{Alnum}/; }
+ $t[3];
+ }), "a";
+
+And welding can still be done on all qw quotes unless the -notrim-qw flag is set.
+
+This fixes case b1189.
+
+7 Aug 2021.
+
=item B<Fix edge cases of formatting instability, b1187 b1188>.
Testing with random parameters produced some cases of instability
This fixes cases b1187 and b1188.
-3 Aug 2021.
+3 Aug 2021, 5be949b.
=item B<Fix edge case of formatting instability, b1186>.
This fixes case b1186.
-2 Aug 2021.
+2 Aug 2021, f3dbee1.
=item B<Fix edge case of formatting instability, b1185>.
This fixes case b1185.
-1 Aug 2021.
+1 Aug 2021, d2ab2b7.
=item B<Fix edge case of formatting instability, b1183>.
This fixes case b1183.
-30 Jul 2021.
+30 Jul 2021, 055650b.
=item B<Fix edge case of formatting instability, b1184>.
This fixes case b1184.
-29 Jul 2021.
+29 Jul 2021, 6dd53fb.
=item B<Fix edge case of formatting instability, b1182>.
This fixes case b1182.
-28 Jul 2021.
+28 Jul 2021, 01d6c40.
=item B<Fix edge case of formatting instability>.