Skip to content

Commit bccf98f

Browse files
committed
endless loop fix
1 parent e324097 commit bccf98f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

examples/editor.pl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,11 @@ sub do_find
371371
my $e = $self-> {editor};
372372
my $p = $self-> {findData};
373373
my @scope;
374+
my $success;
374375
FIND:{
375-
if ( $$p{scope} != fds::Cursor) {
376+
if ( !@scope && $$p{scope} != fds::Cursor) {
376377
if ( $e-> has_selection) {
377-
my @sel = $e-> selection;
378+
my @sel = $e-> selection;
378379
@scope = ($$p{scope} == fds::Top) ? ($sel[0],$sel[1]) : ($sel[2], $sel[3]);
379380
} else {
380381
@scope = ($$p{scope} == fds::Top) ? (0,0) : (-1,-1);
@@ -384,7 +385,12 @@ sub do_find
384385
}
385386
my @n = $e-> find( $$p{findText}, @scope, $$p{replaceText}, $$p{options});
386387
if ( !defined $n[0]) {
387-
Prima::MsgBox::message("No matches found");
388+
Prima::MsgBox::message_box(
389+
$self->text,
390+
$success ?
391+
("All done", mb::Information) :
392+
("No matches found", mb::Error)
393+
);
388394
return;
389395
}
390396
$e-> cursor(($$p{options} & fdo::BackwardSearch) ? $n[0] : $n[2], $n[1]);
@@ -399,6 +405,7 @@ sub do_find
399405
last FIND if $r == mb::Cancel;
400406
}
401407
$e-> set_line( $n[1], $n[3]);
408+
$success = 1;
402409
redo FIND if $$p{result} == mb::ChangeAll;
403410
}
404411
}

0 commit comments

Comments
 (0)