From 674ab835e8638f050237378c195040a5b7f19397 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 13 Jul 2015 05:32:17 +0000 Subject: [PATCH] Arh! I tested that without actually making any spell correction. That wasn't very clever. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5296 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 6 ++---- src/text.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3a90483..8de878de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,6 @@ 2015-07-12 Benno Schulenberg - * src/text.c (do_int_spell_fix, do_alt_speller): Remove the variable - 'added_magicline', as it will always be FALSE and thus does nothing. - * src/text.c (do_alt_speller): Rename the variable 'totsize_save' to - 'size_of_surrounding', to better describe what it contains. + * src/text.c (do_alt_speller): Rename the variable 'totsize_save' + to 'size_of_surrounding', to better describe what it contains. * src/files.c (read_file): Remove a stray space from a message. 2015-07-10 Benno Schulenberg diff --git a/src/text.c b/src/text.c index 4ae63b60..74cede2c 100644 --- a/src/text.c +++ b/src/text.c @@ -2321,6 +2321,8 @@ bool do_int_spell_fix(const char *word) /* A storage place for the current flag settings. */ #ifndef NANO_TINY bool old_mark_set = openfile->mark_set; + bool added_magicline = FALSE; + /* Whether we added a magicline after filebot. */ bool right_side_up = FALSE; /* TRUE if (mark_begin, mark_begin_x) is the top of the mark, * FALSE if (current, current_x) is. */ @@ -2363,6 +2365,8 @@ bool do_int_spell_fix(const char *word) mark_order((const filestruct **)&top, &top_x, (const filestruct **)&bot, &bot_x, &right_side_up); filepart = partition_filestruct(top, top_x, bot, bot_x); + if (!ISSET(NO_NEWLINES)) + added_magicline = (openfile->filebot->data[0] != '\0'); openfile->mark_set = FALSE; } #endif @@ -2414,6 +2418,11 @@ bool do_int_spell_fix(const char *word) #ifndef NANO_TINY if (old_mark_set) { + /* If the mark was on, the NO_NEWLINES flag isn't set, and we + * added a magicline, remove it now. */ + if (!ISSET(NO_NEWLINES) && added_magicline) + remove_magicline(); + /* Put the beginning and the end of the mark at the beginning * and the end of the spell-checked text. */ if (openfile->fileage == openfile->filebot) @@ -2648,6 +2657,8 @@ const char *do_alt_speller(char *tempfile_name) static char **spellargs = NULL; #ifndef NANO_TINY bool old_mark_set = openfile->mark_set; + bool added_magicline = FALSE; + /* Whether we added a magicline after filebot. */ filestruct *top, *bot; size_t top_x, bot_x; bool right_side_up = FALSE; @@ -2747,6 +2758,8 @@ const char *do_alt_speller(char *tempfile_name) mark_order((const filestruct **)&top, &top_x, (const filestruct **)&bot, &bot_x, &right_side_up); filepart = partition_filestruct(top, top_x, bot, bot_x); + if (!ISSET(NO_NEWLINES)) + added_magicline = (openfile->filebot->data[0] != '\0'); /* Compute the size of the text outside of the marked region. */ size_of_surrounding = openfile->totsize - get_totsize(top, bot); @@ -2767,6 +2780,11 @@ const char *do_alt_speller(char *tempfile_name) else openfile->mark_begin_x = strlen(openfile->filebot->data); + /* If the mark was on, the NO_NEWLINES flag isn't set, and we + * added a magicline, remove it now. */ + if (!ISSET(NO_NEWLINES) && added_magicline) + remove_magicline(); + /* Unpartition the filestruct so that it contains all the text * again. Note that we've replaced the marked text originally * in the partition with the spell-checked marked text in the