Adjusting the end point of the marked region to compensate

for any change in length of the region's last line.
Patch by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5169 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2015-03-27 20:16:36 +00:00
parent 14a9c8aa0b
commit 6f2da6b9b2
2 changed files with 13 additions and 8 deletions

View File

@ -1,3 +1,7 @@
2015-03-27 Mark Majeres <mark@engine12.com>
* src/text.c (do_alt_speller): Adjust the end point of the marked
region for any change in length of the region's last line.
2015-03-27 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/patch.nanorc: Recognize also Debian package diffs.
Fixes https://bugs.launchpad.net/ubuntu/+source/nano/+bug/1300565

View File

@ -2675,6 +2675,7 @@ const char *do_alt_speller(char *tempfile_name)
/* Whether we added a magicline after filebot. */
filestruct *top, *bot;
size_t top_x, bot_x;
bool right_side_up = FALSE;
ssize_t mb_lineno_save = 0;
/* We're going to close the current file, and open the output of
* the alternate spell command. The line that mark_begin points
@ -2779,7 +2780,7 @@ const char *do_alt_speller(char *tempfile_name)
* 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 @@ const char *do_alt_speller(char *tempfile_name)
#ifndef NANO_TINY
if (old_mark_set) {
filestruct *top_save = openfile->fileage;
/* Adjust the end point of the marked region for any change in
length of the region's last line. */
if (right_side_up)
current_x_save = strlen(openfile->filebot->data);
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,13 +2825,7 @@ const char *do_alt_speller(char *tempfile_name)
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;
/* 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;
openfile->mark_begin = fsfromline(mb_lineno_save);
/* Turn the mark back on. */
openfile->mark_set = TRUE;