{
char *save_search;
char *save_replace;
- size_t current_x_save = current_x;
- filestruct *current_save = current;
+ size_t current_x_save = current_x, pww_save = placewewant;
filestruct *edittop_save = edittop;
+ filestruct *current_save = current;
/* Save where we are. */
bool accepted = TRUE;
/* The return value. */
last_replace = mallocstrcpy(NULL, word);
/* Start from the top of the file. */
+ edittop = fileage;
current = fileage;
current_x = -1;
+ placewewant = 0;
search_last_line = FALSE;
last_replace = save_replace;
/* Restore where we were. */
+ edittop = edittop_save;
current = current_save;
current_x = current_x_save;
- edittop = edittop_save;
+ placewewant = pww_save;
/* Restore case sensitivity setting. */
if (!case_sens_set)
break;
}
- /* Finished processing file, get out. */
+ /* We've finished processing the file, so get out. */
if (search_last_line) {
if (can_display_wrap)
not_found_msg(needle);
}
#endif
- /* Start or end of buffer reached; wrap around. */
+ /* Start or end of buffer reached, so wrap around. */
if (fileptr == NULL) {
if (!can_display_wrap)
return FALSE;
if (old_mark_set) {
/* Save the locations where the mark begins and ends. */
+ filestruct *old_current = current;
+ size_t old_current_x = current_x;
+
+ current = real_current;
+ current_x = *real_current_x;
mark_order(&top, &top_x, &bot, &bot_x);
+ current = old_current;
+ current_x = old_current_x;
UNSET(MARK_ISSET);
edit_refresh();
*real_current_x += length_change;
}
-#ifndef NANO_SMALL
- /* Since the locations where the mark begins and ends may
- * have changed, keep our saved locations in sync with
- * them. */
- if (old_mark_set) {
- filestruct *old_current = current;
- size_t old_current_x = current_x;
-
- current = real_current;
- current_x = *real_current_x;
- mark_order(&top, &top_x, &bot, &bot_x);
- current = old_current;
- current_x = old_current_x;
- }
-#endif
-
/* Set the cursor at the last character of the replacement
* text, so searching will resume after the replacement
* text. Note that current_x might be set to -1 here. */
set_modified();
numreplaced++;
}
+
+ /* Save the locations where the mark begins and ends again,
+ * since they may have changed. */
+ if (old_mark_set) {
+ filestruct *old_current = current;
+ size_t old_current_x = current_x;
+
+ current = real_current;
+ current_x = *real_current_x;
+ mark_order(&top, &top_x, &bot, &bot_x);
+ current = old_current;
+ current_x = old_current_x;
+ }
}
/* If text has been added to the magicline, make a new magicline. */