Updating 'mark_begin' when mark and cursor are on the same line.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4591 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-02-22 16:46:27 +00:00
parent d6e39724d8
commit 724950701a
2 changed files with 12 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2014-02-22 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (move_to_filestruct) - Update the data in 'mark_begin'
when mark and cursor are on the same line. This avoids a segfault
after M-A, right, M-T, left, ^K, or a hang when the left is left out.
2014-02-22 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main) - Add two conditions on ENABLE_NANORC.
* src/files.c (close_buffer, do_insertfile) - Likewise.

View File

@ -297,6 +297,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
bool edittop_inside;
#ifndef NANO_TINY
bool mark_inside = FALSE;
bool same_line = FALSE;
#endif
assert(file_top != NULL && file_bot != NULL && top != NULL && bot != NULL);
@ -314,7 +315,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
openfile->fileage->lineno && openfile->edittop->lineno <=
openfile->filebot->lineno);
#ifndef NANO_TINY
if (openfile->mark_set)
if (openfile->mark_set) {
mark_inside = (openfile->mark_begin->lineno >=
openfile->fileage->lineno &&
openfile->mark_begin->lineno <=
@ -323,6 +324,8 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
openfile->mark_begin_x >= top_x) &&
(openfile->mark_begin != openfile->filebot ||
openfile->mark_begin_x <= bot_x));
same_line = (openfile->mark_begin == openfile->fileage);
}
#endif
/* Get the number of characters in the text, and subtract it from
@ -382,7 +385,9 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
if (mark_inside) {
openfile->mark_begin = openfile->current;
openfile->mark_begin_x = openfile->current_x;
}
} else if (same_line)
/* update the content of this partially cut line */
openfile->mark_begin = openfile->current;
#endif
top_save = openfile->fileage;