display: don't draw more chunks than the screen can hold
There is no need to always increase nrows by 1 or 2 -- an increase of 1 is only needed when the line that borders on the scrolled region needs to redrawn too: when this line was horizontally scrolled or when the mark is on. This fixes https://savannah.gnu.org/bugs/?50621. Reported-by: David Lawrence Ramsey <pooka109@gmail.com>master
parent
d01756bb69
commit
66ef8f45a3
39
src/winio.c
39
src/winio.c
|
@ -2902,14 +2902,10 @@ void edit_scroll(scroll_dir direction, int nrows)
|
||||||
/* Part 2: nrows is now the number of rows in the scrolled region of the
|
/* Part 2: nrows is now the number of rows in the scrolled region of the
|
||||||
* edit window that we need to draw. */
|
* edit window that we need to draw. */
|
||||||
|
|
||||||
/* If the scrolled region contains only one row, and the row before it is
|
/* If we're not on the first "page" (when not softwrapping), or the mark
|
||||||
* visible in the edit window, we need to draw it too. If the scrolled
|
* is on, the row next to the scrolled region needs to be redrawn too. */
|
||||||
* region is more than one row, and the rows before and after it are
|
if (line_needs_update(openfile->placewewant, 0) && nrows < editwinrows)
|
||||||
* visible in the edit window, we need to draw them too. */
|
nrows++;
|
||||||
nrows += (nrows == 1) ? 1 : 2;
|
|
||||||
|
|
||||||
if (nrows > editwinrows)
|
|
||||||
nrows = editwinrows;
|
|
||||||
|
|
||||||
/* If we scrolled up, we're on the line before the scrolled region. */
|
/* If we scrolled up, we're on the line before the scrolled region. */
|
||||||
line = openfile->edittop;
|
line = openfile->edittop;
|
||||||
|
@ -2919,21 +2915,18 @@ void edit_scroll(scroll_dir direction, int nrows)
|
||||||
if (direction == DOWNWARD)
|
if (direction == DOWNWARD)
|
||||||
go_forward_chunks(editwinrows - nrows, &line, &leftedge);
|
go_forward_chunks(editwinrows - nrows, &line, &leftedge);
|
||||||
|
|
||||||
/* Draw new lines on any blank rows before or inside the scrolled region.
|
/* Draw new content on the blank rows inside the scrolled region
|
||||||
* If we're not in softwrap mode, we can optimize one case: if we scrolled
|
* (and on the bordering row too when it was deemed necessary). */
|
||||||
* forward and we're on the top row, or if we scrolled backward and we're
|
i = nrows;
|
||||||
* on the bottom row, the row won't be blank, so we don't need to draw it
|
while (i > 0 && line != NULL) {
|
||||||
* unless the mark is on or we're not on the first "page". */
|
#ifndef NANO_TINY
|
||||||
for (i = nrows; i > 0 && line != NULL; i--) {
|
/* If the first blank row is in the middle of a softwrapped line,
|
||||||
if (!ISSET(SOFTWRAP) &&
|
* compensate for the earlier chunks of that line. */
|
||||||
((i == 1 && direction == UPWARD) ||
|
if (ISSET(SOFTWRAP) && i == nrows)
|
||||||
(i == nrows && direction == DOWNWARD))) {
|
i += strnlenpt(line->data, leftedge) / editwincols;
|
||||||
if (line_needs_update(openfile->placewewant, 0))
|
#endif
|
||||||
update_line(line, (line == openfile->current) ?
|
i -= update_line(line, (line == openfile->current) ?
|
||||||
openfile->current_x : 0);
|
openfile->current_x : 0);
|
||||||
} else
|
|
||||||
update_line(line, (line == openfile->current) ?
|
|
||||||
openfile->current_x : 0);
|
|
||||||
line = line->next;
|
line = line->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue