]> git.donarmstrong.com Git - perltidy.git/commitdiff
indicate location of error parsing -ias=s with underline
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 9 Feb 2024 14:56:59 +0000 (06:56 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 9 Feb 2024 14:56:59 +0000 (06:56 -0800)
lib/Perl/Tidy/Formatter.pm

index 3ecb5da5994e173c6133bf82802931b2c30e6f42..0c2ea356c09c261946500a7be1b52e784a28a12d 100644 (file)
@@ -2893,7 +2893,9 @@ EOM
     my %rule_hash;
     my ( $ch1, $ch2 );
     my $err_msg;
+    my $pos_last;
     while (1) {
+        $pos_last = pos($opt_style);
         if (
             $opt_style =~ m{
              \G
@@ -2946,8 +2948,12 @@ EOM
     }
 
     if ($err_msg) {
-        my $pos = pos($opt_style);    # could display location
-        Die("Error parsing --$name_style: $err_msg\n");
+        my $msg;
+        if ( $pos_last && length($opt_style) < 20 ) {
+            $msg = $opt_style . "\n" . SPACE x $pos_last . '^' . "\n";
+        }
+        $msg .= "Error parsing --$name_style: $err_msg";
+        Die($msg);
     }
 
     # Copy the rule hash, converting braces to token types