From e95cb89f1313e5cf1883c4b44df7f4a8230edbc8 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 9 Feb 2024 06:56:59 -0800 Subject: [PATCH] indicate location of error parsing -ias=s with underline --- lib/Perl/Tidy/Formatter.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 -- 2.39.5