## 2024 09 03.09
+ - If a file consists only of comments, then the starting indentation will
+ be guessed from the indentation of the first comment. Previously it would
+ be guessed to be zero. Parameter --starting-indentation-level=n can be
+ used to specify an indentation and avoid a guess. This issue can
+ arise when formatting a block of comments from within an editor.
+
- Added missing 'use File::Temp' for -html option. This was causing the
message: "Undefined subroutine &File::Temp::tempfile called at ..."
See git #176.
# ( or, for now, an =pod line)
my $msg = EMPTY_STRING;
my $in_code_skipping;
+ my $line_for_guess;
while ( defined( $line = $self->peek_ahead( $i++ ) ) ) {
# if first line is #! then assume starting level is zero
# ignore lines fenced off with code-skipping comments
if ( $line =~ /^\s*#/ ) {
+
+ # use first comment for indentation guess in case of no code
+ if ( !defined($line_for_guess) ) { $line_for_guess = $line }
+
if ( !$in_code_skipping ) {
if ( $rOpts_code_skipping
&& $line =~ /$code_skipping_pattern_begin/ )
next if ( $line =~ /^\s*$/ ); # skip past blank lines
- $starting_level = $self->guess_old_indentation_level($line);
+ # use first line of code for indentation guess
+ $line_for_guess = $line;
last;
} ## end while ( defined( $line = ...))
+
+ if ( defined($line_for_guess) ) {
+ $starting_level =
+ $self->guess_old_indentation_level($line_for_guess);
+ }
$msg = "Line $i implies starting-indentation-level = $starting_level\n";
$self->write_logfile_entry("$msg");
}