softwrap: save and restore firstcolumn when copying text

Copying text involves first cutting it and then quickly pasting it back.
However, cutting the text may change firstcolumn if the mark is offscreen.
To keep the viewport unchanged, copy_text() has to save and restore not
just edittop, but firstcolumn as well.
master
David Lawrence Ramsey 2017-01-24 21:51:23 -06:00 committed by Benno Schulenberg
parent dd08b638c1
commit 6f0ed2075c
1 changed files with 2 additions and 0 deletions

View File

@ -225,6 +225,7 @@ void do_copy_text(void)
/* Remember the current viewport and cursor position. */ /* Remember the current viewport and cursor position. */
ssize_t is_edittop_lineno = openfile->edittop->lineno; ssize_t is_edittop_lineno = openfile->edittop->lineno;
size_t is_firstcolumn = openfile->firstcolumn;
ssize_t is_current_lineno = openfile->current->lineno; ssize_t is_current_lineno = openfile->current->lineno;
size_t is_current_x = openfile->current_x; size_t is_current_x = openfile->current_x;
@ -239,6 +240,7 @@ void do_copy_text(void)
if (mark_set) { if (mark_set) {
/* Restore the viewport and cursor position. */ /* Restore the viewport and cursor position. */
openfile->edittop = fsfromline(is_edittop_lineno); openfile->edittop = fsfromline(is_edittop_lineno);
openfile->firstcolumn = is_firstcolumn;
openfile->current = fsfromline(is_current_lineno); openfile->current = fsfromline(is_current_lineno);
openfile->current_x = is_current_x; openfile->current_x = is_current_x;
} }