From 88a4da97478ec6b4b2f361315a5a183333d0aa3f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 15 May 2013 15:39:51 +0000 Subject: [PATCH] Don't let cursor position overflow when reflowing, from Christopher Collins. --- screen.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/screen.c b/screen.c index 754effc2..76aa91c6 100644 --- a/screen.c +++ b/screen.c @@ -365,7 +365,13 @@ void screen_reflow(struct screen *s, u_int new_x) { struct grid *old = s->grid; + u_int change; s->grid = grid_create(old->sx, old->sy, old->hlimit); - s->cy -= grid_reflow(s->grid, old, new_x); + + change = grid_reflow(s->grid, old, new_x); + if (change < s->cy) + s->cy -= change; + else + s->cy = 0; }