]> git.donarmstrong.com Git - perltidy.git/commitdiff
Update rule for spacing paren after constant function
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 26 Feb 2021 15:57:00 +0000 (07:57 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 26 Feb 2021 15:57:00 +0000 (07:57 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 1b179eb6065b0180a374a6c21f1c0d588b493379..1c10b85a8368fdc13dfc53b9f46220ff72001bc8 100644 (file)
@@ -2156,7 +2156,8 @@ sub set_whitespace_flags {
             # 'w' and 'i' checks for something like:
             #   myfun(    &myfun(   ->myfun(
             # -----------------------------------------------------
-            elsif (( $last_type =~ /^[wUG]$/ )
+            # Patch: added 'C' to prevent blinker, case b934, i.e. 'pi()'
+            elsif (( $last_type =~ /^[wCUG]$/ )
                 || ( $last_type =~ /^[wi]$/ && $last_token =~ /^(\&|->)/ ) )
             {
                 $ws = WS_NO unless ($rOpts_space_function_paren);
index 4e3ab8572a09b1f42b96d379a5444ddb2828da81..9a9f25709b542aad76e845c12ab3c850cc89012a 100644 (file)
@@ -2,6 +2,31 @@
 
 =over 4
 
+=item B<Update rule for spacing paren after constant function>
+
+Random testing produced an unstable state for the following snippet (case b934)
+
+        sub pi();
+        if (
+            $t >
+            pi( )
+              )
+
+when run with these parameters:
+
+  --continuation-indentation=6
+  --maximum-line-length=17
+  --paren-vertical-tightness-closing=2
+
+The formatting was stable without the first line, which declares 'pi' to be
+a constant sub.  The problem was fixed by updating a regex to treat the spacing
+of a paren following a sub the same for the two token types, 'U' or 'C' 
+(constant function).
+
+This fixes case b934.
+
+26 Feb 2021.
+
 =item B<Improve line length test for the -vtc=2 option>
 
 This is a small change to the update of 13 Feb 2021, f79a4f1. Random testing