From: Steve Hancock Date: Fri, 9 Feb 2024 14:56:59 +0000 (-0800) Subject: indicate location of error parsing -ias=s with underline X-Git-Tag: 20240202.02~13 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e95cb89f1313e5cf1883c4b44df7f4a8230edbc8;p=perltidy.git indicate location of error parsing -ias=s with underline --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 3ecb5da5..0c2ea356 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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