From: David Lawrence Ramsey Date: Mon, 18 Oct 2004 02:06:53 +0000 (+0000) Subject: rearrange the mark-handling code in do_replace_loop() a bit, and add one X-Git-Tag: v1.3.5~123 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=2cc2a57deae836af17a59a279c3f26fe731312d7;p=nano.git rearrange the mark-handling code in do_replace_loop() a bit, and add one more miscellaneous fix git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1997 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/src/nano.c b/src/nano.c index 08b36507..b6a55783 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1420,9 +1420,9 @@ bool do_int_spell_fix(const char *word) { 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. */ @@ -1463,8 +1463,10 @@ bool do_int_spell_fix(const char *word) 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; @@ -1500,9 +1502,10 @@ bool do_int_spell_fix(const char *word) 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) diff --git a/src/search.c b/src/search.c index d2f0105c..3be17736 100644 --- a/src/search.c +++ b/src/search.c @@ -299,7 +299,7 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool 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); @@ -318,7 +318,7 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool } #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; @@ -626,7 +626,14 @@ int do_replace_loop(const char *needle, filestruct *real_current, size_t 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(); @@ -747,22 +754,6 @@ int do_replace_loop(const char *needle, filestruct *real_current, size_t *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. */ @@ -788,6 +779,19 @@ int do_replace_loop(const char *needle, filestruct *real_current, size_t 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. */