tweaks: reduce a bit of mark-adjusting code to its essence

It doesn't matter whether the grafted text contains a newline or not.

It only matters whether the mark was before or after the cursor.  When
it was after the cursor, the mark needs to be set to the bottom line of
the grafted text and its x coordinate needs adjustment; and when it was
before the cursor, the mark just needs to be set to the top line of the
grafted text.
master
Benno Schulenberg 2019-04-28 12:02:38 +02:00
parent 065afe6e0f
commit d54180ad8b
1 changed files with 5 additions and 11 deletions

View File

@ -431,20 +431,14 @@ void ingraft_buffer(linestruct *somebuffer)
openfile->current_x += current_x_save;
#ifndef NANO_TINY
/* Refresh the mark's pointer, and compensate the mark's
/* When needed, refresh the mark's pointer and compensate the mark's
* x coordinate for the change in the current line. */
if (openfile->mark && single_line) {
if (openfile->filetop == openfile->filebot) {
openfile->mark = openfile->current;
if (!right_side_up)
openfile->mark_x += openfile->current_x - current_x_save;
} else
if (right_side_up)
openfile->mark = openfile->filetop;
else {
openfile->mark = openfile->current;
if (!right_side_up) {
openfile->mark = openfile->filebot;
openfile->mark_x += openfile->current_x - current_x_save;
}
} else
openfile->mark = openfile->filetop;
}
#endif