softwrap: adjust start-of-screen when the 'edittop' line is hard-wrapped

When one or more chunks of the current line are above the viewport,
and this line gets hard-wrapped, then 'edittop' needs to be advanced,
otherwise the first row could be blank -- representing a chunk that
doesn't exist any more.

This fixes https://savannah.gnu.org/bugs/?65604.
The issue was reported by `correctmost`.

Bug existed since version 2.8.6, commit e375995d.
This commit is contained in:
Benno Schulenberg 2024-04-17 16:35:51 +02:00
parent c02aec557c
commit 7b07e1ee5c
1 changed files with 6 additions and 0 deletions

View File

@ -1339,6 +1339,12 @@ void do_wrap(void)
/* Now split the line. */
do_enter();
#ifndef NANO_TINY
/* When wrapping a partially visible line, adjust start-of-screen. */
if (openfile->edittop == line && openfile->firstcolumn > 0 && cursor_x >= wrap_loc)
go_forward_chunks(1, &openfile->edittop, &openfile->firstcolumn);
#endif
#ifdef ENABLE_JUSTIFY
/* If the original line has quoting, copy it to the spillage line. */
if (quot_len > 0) {