From: Steve Hancock Date: Wed, 16 Oct 2024 00:21:15 +0000 (-0700) Subject: fix -qwaf issue with backslash before closing paren, c414 X-Git-Tag: 20240903.05~26 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f61b0e96e59160454f435f02b2b0bb6424f89dd6;p=perltidy.git fix -qwaf issue with backslash before closing paren, c414 --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index b621d258..93cd6d5c 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -7061,6 +7061,23 @@ EOM return; } + # c414: do not join a '\' and a closing ')' for example like here: + # my @clock_chars = qw( | / - \ | / - \ ); + if ( + @words + && $closing + && substr( $words[-1], -1, 1 ) eq '\\' + && ( $tightness{')'} == 2 + || $tightness{')'} == 1 && @words == 1 ) + ) + { + # fix by including a space after the \ + $words[-1] .= SPACE; + + # and for symmetry, before the first word if the '(' is on this line + if ($opening) { $words[0] = SPACE . $words[0] } + } + #--------------------------------------------------------------------- # This is the point of no return if the transformation has not started #--------------------------------------------------------------------- diff --git a/t/snippets/expect/qwaf.def b/t/snippets/expect/qwaf.def index 1e3a0fad..8229e0ee 100644 --- a/t/snippets/expect/qwaf.def +++ b/t/snippets/expect/qwaf.def @@ -25,3 +25,4 @@ use Digest::MD5 qw( md5_hex ); SlateBlue1 ); +@list = qw( \ ); diff --git a/t/snippets/expect/qwaf.qwaf b/t/snippets/expect/qwaf.qwaf index 0a781fc4..1413a70d 100644 --- a/t/snippets/expect/qwaf.qwaf +++ b/t/snippets/expect/qwaf.qwaf @@ -19,3 +19,4 @@ use Digest::MD5 qw(md5_hex); SlateBlue1 ); +@list = qw( \ ); diff --git a/t/snippets/qwaf.in b/t/snippets/qwaf.in index 63ab2480..e9663e96 100644 --- a/t/snippets/qwaf.in +++ b/t/snippets/qwaf.in @@ -25,3 +25,4 @@ use Digest::MD5 qw( md5_hex ); SlateBlue1 ); +@list = qw( \ ); diff --git a/t/snippets30.t b/t/snippets30.t index dcc3050e..3170b972 100644 --- a/t/snippets30.t +++ b/t/snippets30.t @@ -179,6 +179,7 @@ use Digest::MD5 qw( md5_hex ); SlateBlue1 ); +@list = qw( \ ); ---------- }; @@ -453,6 +454,7 @@ use Digest::MD5 qw( md5_hex ); SlateBlue1 ); +@list = qw( \ ); #17........... }, @@ -481,6 +483,7 @@ use Digest::MD5 qw(md5_hex); SlateBlue1 ); +@list = qw( \ ); #18........... }, };