From 538688f587c1f3395e20b81cac64e1812f20af2f Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 24 Dec 2020 10:06:31 -0800 Subject: [PATCH] modify rule for outdenting non-container closing qw delimiters --- lib/Perl/Tidy/Formatter.pm | 13 ++++++++++--- local-docs/BugLog.pod | 25 +++++++++++++++++++------ t/snippets/expect/ndsm1.def | 2 +- t/snippets/expect/ndsm1.ndsm | 2 +- t/snippets16.t | 4 ++-- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index a3d24449..6f663254 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -18983,15 +18983,22 @@ sub make_paren_name { # A quote delimiter which is not a container will not have # a cti value defined. In this case use the style of a # paren. For example - # my @words = ( - # qw/ + # my @fars = ( + # qw< # far # farfar # farfars far - # /, + # >, # ); if ( !defined($cti) && length($tok) == 1 ) { + + # something other than ')', '}', ']' ; use flag for ')' $cti = $closing_token_indentation{')'}; + + # But for now, do not outdent non-container qw + # delimiters because it would would change existing + # formatting. + if ( $tok ne '>' ) { $cti = 3 } } # A non-welded closing qw cannot currently use -cti=1 diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index e7ff6522..73a5d7c9 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -76,21 +76,34 @@ followed the default -cpi setting for a paren: ); This update makes closing qw quote terminators follow the settings for their -corresponding container tokens as closely as possible. In addition, for -closing quote tokens which are not containers, the setting for a closing paren -will now be followed. For example +corresponding container tokens as closely as possible. For a closing '>' +the setting for a closing paren will now be followed. Other closing qw +terminators will remain indented, to minimize changes to existing formatting. +For example ('>' is outdented): @EXPORT = ( - qw# + qw< i Re Im rho theta arg sqrt log ln log10 logn cbrt root cplx cplxe - #, + >, @trig ); -This update was added 18 Dec 2020. +but (';' remains indented): + + @EXPORT = ( + qw; + i Re Im rho theta arg + sqrt log ln + log10 logn cbrt root + cplx cplxe + ;, + @trig + ); + +This update was added 18 Dec 2020 and modified 24 Dec. =item B diff --git a/t/snippets/expect/ndsm1.def b/t/snippets/expect/ndsm1.def index c2b812f3..c36b944f 100644 --- a/t/snippets/expect/ndsm1.def +++ b/t/snippets/expect/ndsm1.def @@ -4,5 +4,5 @@ sub numerically { $a <=> $b } sub Numerically { $a <=> $b }; # trapped semicolon @: = qw;2c72656b636168 2020202020 -;; + ;; __; diff --git a/t/snippets/expect/ndsm1.ndsm b/t/snippets/expect/ndsm1.ndsm index e79a123f..d5e53dd9 100644 --- a/t/snippets/expect/ndsm1.ndsm +++ b/t/snippets/expect/ndsm1.ndsm @@ -12,5 +12,5 @@ sub numerically { $a <=> $b }; sub Numerically { $a <=> $b }; # trapped semicolon @: = qw;2c72656b636168 2020202020 -;; + ;; __; diff --git a/t/snippets16.t b/t/snippets16.t index d70fc960..5951bf60 100644 --- a/t/snippets16.t +++ b/t/snippets16.t @@ -355,7 +355,7 @@ sub numerically { $a <=> $b } sub Numerically { $a <=> $b }; # trapped semicolon @: = qw;2c72656b636168 2020202020 -;; + ;; __; #14........... }, @@ -378,7 +378,7 @@ sub numerically { $a <=> $b }; sub Numerically { $a <=> $b }; # trapped semicolon @: = qw;2c72656b636168 2020202020 -;; + ;; __; #15........... }, -- 2.39.5