From 35104c510ca1d048d2d5ec3283d0048564552a7e Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 1 Nov 2023 18:56:14 -0700 Subject: [PATCH] check for negative -i and -ci --- lib/Perl/Tidy.pm | 10 ++++++++++ lib/Perl/Tidy/Tokenizer.pm | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 70c6e35d..a97470e1 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -4554,6 +4554,16 @@ sub check_options { EOM } + # do not allow negative --indent-columns + if ( $rOpts->{'indent-columns'} < 0 ) { + $rOpts->{'indent-columns'} = 0; + } + + # negative ci is currently allowed provided that ci+i is not negative + if ( $rOpts->{'continuation-indentation'} < -$rOpts->{'indent-columns'} ) { + $rOpts->{'continuation-indentation'} = -$rOpts->{'indent-columns'}; + } + my $sil = $rOpts->{'starting-indentation-level'}; if ( defined($sil) && $sil < 0 ) { Die(< 0 ) + { $spaces += $rOpts_continuation_indentation; } } -- 2.39.5