Index: src/search.c =================================================================== --- src/search.c (revision 5172) +++ src/search.c (working copy) @@ -704,12 +704,13 @@ * partition, turn the mark off, and refresh the screen. */ mark_order((const filestruct **)&top, &top_x, (const filestruct **)&bot, &bot_x, &right_side_up); - filepart = partition_filestruct(top, top_x, bot, bot_x); - openfile->edittop = openfile->fileage; openfile->mark_set = FALSE; #ifndef DISABLE_COLOR reset_multis(openfile->current, TRUE); #endif + openfile->current = top; + openfile->current_x = (top_x == 0 ? 0 : top_x - 1); + edit_refresh(); } #endif /* !NANO_TINY */ @@ -734,6 +735,16 @@ , real_current, *real_current_x, needle, &match_len)) { int i = 0; +#ifndef NANO_TINY + if (old_mark_set && (openfile->current->lineno > bot->lineno || + openfile->current->lineno < top->lineno)) + break; + if (old_mark_set && openfile->current == bot && openfile->current_x > *real_current_x) + break; + if (old_mark_set && openfile->current == top && openfile->current_x < top_x) + break; +#endif + #ifdef HAVE_REGEX_H /* If the bol_or_eol flag is set, we've found a match on the * beginning line already, and we're still on the beginning line @@ -794,7 +805,7 @@ size_t length_change; #ifndef NANO_TINY - update_undo(REPLACE); + add_undo(REPLACE); #endif if (i == 2) replaceall = TRUE; @@ -874,7 +885,6 @@ /* If the mark was on, unpartition the filestruct so that it * contains all the text again, set edittop back to what it was * before, turn the mark back on, and refresh the screen. */ - unpartition_filestruct(&filepart); openfile->edittop = edittop_save; openfile->mark_set = TRUE; }