softwrap: properly update the viewport when adding text at firstcolumn

Adding text plus whitespace while the cursor is at or near the topleft
corner of the edit window can cause a change in the preceding chunk,
throwing firstcolumn out of alignment.  Catch this special case.

This fixes http://savannah.gnu.org/bugs/?51743.
master
David Lawrence Ramsey 2017-08-13 04:30:10 -05:00 committed by Benno Schulenberg
parent 3ab943c49a
commit 8e779b6e85
1 changed files with 9 additions and 0 deletions

View File

@ -1855,6 +1855,15 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
if (openfile->mark_set && openfile->current == openfile->mark_begin &&
openfile->current_x < openfile->mark_begin_x)
openfile->mark_begin_x += char_len;
/* When the cursor is on the top row and not on the first chunk
* of a line, adding text there might change the preceding chunk
* and thus require an adjustment of firstcolumn. */
if (openfile->current == openfile->edittop &&
openfile->firstcolumn > 0) {
ensure_firstcolumn_is_aligned();
refresh_needed = TRUE;
}
#endif
openfile->current_x += char_len;