summaryrefslogtreecommitdiffstats
path: root/src/drawscreen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/drawscreen.c')
-rw-r--r--src/drawscreen.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 578c66f2b9..a5822b25d8 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -1808,9 +1808,13 @@ win_update(win_T *wp)
// Move the entries that were scrolled, disable
// the entries for the lines to be redrawn.
+ // Avoid using a wrong index when 'cmdheight' is
+ // zero and wp->w_height == Rows.
if ((wp->w_lines_valid += j) > wp->w_height)
wp->w_lines_valid = wp->w_height;
- for (idx = wp->w_lines_valid; idx - j >= 0; idx--)
+ for (idx = wp->w_lines_valid >= wp->w_height
+ ? wp->w_height - 1 : wp->w_lines_valid;
+ idx - j >= 0; idx--)
wp->w_lines[idx] = wp->w_lines[idx - j];
while (idx >= 0)
wp->w_lines[idx--].wl_valid = FALSE;