Index: src/text.c =================================================================== --- src/text.c (revision 5159) +++ src/text.c (working copy) @@ -2676,6 +2676,7 @@ filestruct *top, *bot; size_t top_x, bot_x; ssize_t mb_lineno_save = 0; + bool right_side_up = FALSE; /* We're going to close the current file, and open the output of * the alternate spell command. The line that mark_begin points * to will be freed, so we save the line number and restore it @@ -2779,7 +2780,7 @@ * added when we're done correcting misspelled words; and * turn the mark off. */ mark_order((const filestruct **)&top, &top_x, - (const filestruct **)&bot, &bot_x, NULL); + (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'); @@ -2797,6 +2798,12 @@ #ifndef NANO_TINY if (old_mark_set) { filestruct *top_save = openfile->fileage; + if(right_side_up){ + openfile->current_x = strlen(openfile->filebot->data); + current_x_save = openfile->current_x; + } + 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. */ @@ -2818,14 +2825,8 @@ openfile->totsize = totsize_save; /* Assign mark_begin to the line where the mark began before. */ - goto_line_posx(mb_lineno_save, openfile->mark_begin_x); - openfile->mark_begin = openfile->current; + openfile->mark_begin = fsfromline(mb_lineno_save); - /* Assign mark_begin_x to the location in mark_begin where the - * mark began before, adjusted for any shortening of the - * line. */ - openfile->mark_begin_x = openfile->current_x; - /* Turn the mark back on. */ openfile->mark_set = TRUE; }