From 13ec5d8ce983c3a474ecb2c3ae6e09bcb5c1b3bc Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 10 Dec 2016 13:20:06 +0100 Subject: [PATCH] spelling: correctly restore the selected region An added magic linefeed should be removed again /before/ restoring the x position, as the latter needs to be calculated from the real last line of the region. This fixes https://savannah.gnu.org/bugs/?49817. Reported-by: Mike Frysinger --- src/text.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/text.c b/src/text.c index e7a03fbd..c03f3d2b 100644 --- a/src/text.c +++ b/src/text.c @@ -3044,6 +3044,11 @@ const char *do_alt_speller(char *tempfile_name) #ifndef NANO_TINY if (old_mark_set) { filestruct *top_save = openfile->fileage; + + /* If a magicline was added, remove it again. */ + if (added_magicline) + remove_magicline(); + /* Adjust the end point of the marked region for any change in * length of the region's last line. */ if (right_side_up) @@ -3051,10 +3056,6 @@ const char *do_alt_speller(char *tempfile_name) else openfile->mark_begin_x = strlen(openfile->filebot->data); - /* If a magicline was added, remove it again. */ - if (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