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 <vapier@gentoo.org>
This commit is contained in:
Benno Schulenberg 2016-12-10 13:20:06 +01:00
parent 30591c5e01
commit 13ec5d8ce9

View File

@ -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