From 339a4e9571c33d37f30d34ef27bd9aa0b8a0ca81 Mon Sep 17 00:00:00 2001
From: Steve Hancock <perltidy@users.sourceforge.net>
Date: Sun, 7 Jan 2024 10:05:21 -0800
Subject: [PATCH] add trailing commas to multiline hash lists

---
 lib/Perl/Tidy.pm                 |  2 +-
 lib/Perl/Tidy/Tokenizer.pm       |  6 +++---
 lib/Perl/Tidy/VerticalAligner.pm |  4 ++--
 perltidyrc                       | 16 ++++++++++++----
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm
index 983af14a..fc9ba6ab 100644
--- a/lib/Perl/Tidy.pm
+++ b/lib/Perl/Tidy.pm
@@ -5288,7 +5288,7 @@ sub Win_OS_Type {
             1  => "XP/.Net",
             2  => "Win2003",
             51 => "NT3.51",
-        }
+        },
     }->{$id}->{$minor};
 
     # If $os is undefined, the above code is out of date.  Suggested updates
diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm
index 47ffbaec..17b058ce 100644
--- a/lib/Perl/Tidy/Tokenizer.pm
+++ b/lib/Perl/Tidy/Tokenizer.pm
@@ -2784,7 +2784,7 @@ EOM
                         last_nonblank_i => $last_nonblank_i,
                         rpretoken_map   => $rtoken_map,
                         rpretoken_type  => $rtoken_type,
-                        input_line      => $input_line
+                        input_line      => $input_line,
                     }
                 );
                 return 1;
@@ -2806,7 +2806,7 @@ EOM
                     last_nonblank_i => $last_nonblank_i,
                     rpretoken_map   => $rtoken_map,
                     rpretoken_type  => $rtoken_type,
-                    input_line      => $input_line
+                    input_line      => $input_line,
                 }
             );
             if ( $i_tok == 0 ) {
@@ -7715,7 +7715,7 @@ sub scan_id_do {
                     type            => $type,
                     rtokens         => $rtokens,
                     rtoken_map      => $rtoken_map,
-                    max_token_index => $max_token_index
+                    max_token_index => $max_token_index,
                 }
             );
             $id_scan_state = EMPTY_STRING;
diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm
index 04d9afe6..6799d28d 100644
--- a/lib/Perl/Tidy/VerticalAligner.pm
+++ b/lib/Perl/Tidy/VerticalAligner.pm
@@ -2295,7 +2295,7 @@ sub sweep_left_to_right {
             rtodo       => \@todo,
             rmax_move   => \%max_move,
             short_pad   => $short_pad,
-            group_level => $group_level
+            group_level => $group_level,
         }
     );
     return;
@@ -3371,7 +3371,7 @@ sub match_line_pairs {
                                 tok_m       => $tok_m,
                                 pat         => $pat,
                                 pat_m       => $pat_m,
-                                pad         => $pad
+                                pad         => $pad,
                             }
                         );
                         if ($match_code) {
diff --git a/perltidyrc b/perltidyrc
index 682b86d4..4c3fb243 100644
--- a/perltidyrc
+++ b/perltidyrc
@@ -1,12 +1,20 @@
-# perltidyrc file for perltidy
-# Note that this is not named .perltidyrc because that would interfere
-# with testing. This has to be requested with -pro=perltidyrc
+# perltidyrc file for perltidy itself
+# Note:
+# - This is not named .perltidyrc because that could interfere
+#   with testing. This has to be requested with -pro=perltidyrc
+# - Formatting without these parameters remains stable, so it is not
+#   necessary to format with these parameters every time. But it should
+#   be done before a commit.
 
 # warnings
 --warning-output
 --warn-missing-else
 --warn-variable-types='*'
 
-# add sub names to closing brace
+# add comment with sub name to closing sub brace
 --closing-side-comments
 --closing-side-comment-list='sub'
+
+# add trailing commas to last item of a bare hash list
+--want-trailing-commas='h'
+--add-trailing-commas
-- 
2.39.5