From 99ac441d3b48bec86a594aceb07da9cd46d558af Mon Sep 17 00:00:00 2001 From: Nigel Date: Tue, 28 Nov 2023 15:22:11 +0000 Subject: [PATCH] Trap AutoIndex bug when no lines to process (#1280) Attempting to run HTML -> AutoIndex when there are no non-blank lines before the end of file, e.g. on empty file, caused an infinite loop --- src/lib/Guiguts/HTMLConvert.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/Guiguts/HTMLConvert.pm b/src/lib/Guiguts/HTMLConvert.pm index 77180264..bc6d4340 100644 --- a/src/lib/Guiguts/HTMLConvert.pm +++ b/src/lib/Guiguts/HTMLConvert.pm @@ -3289,8 +3289,11 @@ sub autoindex { my $first = 1; my $indent = 0; + my $endstep = $textwindow->index('end'); + $endstep =~ s/\..*//; while ( $textwindow->get( "$step.0", "$step.end" ) eq '' ) { $step++; + return if $step >= $endstep; } while ( $step <= $ler ) { my $selection = $textwindow->get( "$step.0", "$step.end" );