diff --git a/src/text.c b/src/text.c index 64aeca60..d087774e 100644 --- a/src/text.c +++ b/src/text.c @@ -2536,8 +2536,6 @@ bool fix_spello(const char *word) /* The return value of this function. */ bool result; /* The return value of searching for a misspelled word. */ - unsigned stash[sizeof(flags) / sizeof(flags[0])]; - /* A storage place for the current flag settings. */ #ifndef NANO_TINY bool right_side_up = FALSE; /* TRUE if (mark_begin, mark_begin_x) is the top of the mark, @@ -2546,9 +2544,6 @@ bool fix_spello(const char *word) size_t top_x, bot_x; #endif - /* Save the settings of the global flags. */ - memcpy(stash, flags, sizeof(flags)); - /* Do the spell checking case sensitive, forward, and without regexes. */ SET(CASE_SENSITIVE); UNSET(BACKWARDS_SEARCH); @@ -2645,9 +2640,6 @@ bool fix_spello(const char *word) openfile->edittop = edittop_save; openfile->firstcolumn = firstcolumn_save; - /* Restore the settings of the global flags. */ - memcpy(flags, stash, sizeof(flags)); - return proceed; } @@ -2944,6 +2936,8 @@ void do_spell(void) bool status; FILE *temp_file; char *temp; + unsigned stash[sizeof(flags) / sizeof(flags[0])]; + /* A storage place for the current flag settings. */ const char *spell_msg; if (ISSET(RESTRICTED)) { @@ -2958,6 +2952,12 @@ void do_spell(void) return; } + /* Save the settings of the global flags. */ + memcpy(stash, flags, sizeof(flags)); + + /* Don't add an extra newline when writing out the (selected) text. */ + SET(NO_NEWLINES); + #ifndef NANO_TINY if (openfile->mark) status = write_marked_file(temp, temp_file, TRUE, OVERWRITE); @@ -2979,6 +2979,9 @@ void do_spell(void) unlink(temp); free(temp); + /* Restore the settings of the global flags. */ + memcpy(flags, stash, sizeof(flags)); + /* If the spell-checker printed any error messages onscreen, make * sure that they're cleared off. */ total_refresh();