From 0625ddc2bcaad60fbc0bb2dc944876b90bda572c Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 26 Feb 2011 14:56:21 +0100 Subject: [PATCH] reset screen offset of top line if it exceeds the number of screens Some operations such as changing the tab size may change the number of screens needed to display a line and may therefore result in the current screen offset to exceed this number of screens. This could in turn result in the entire screen not being populated properly. This patch detects and corrects this situation while populating the screen after reformatting. Problem reported and fixed by patrick keshishian --- vi/vs_smap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vi/vs_smap.c b/vi/vs_smap.c index db4c9bb6..92284b75 100644 --- a/vi/vs_smap.c +++ b/vi/vs_smap.c @@ -224,6 +224,16 @@ vs_sm_fill(SCR *sp, db_recno_t lno, pos_t pos) top: HMAP->lno = lno; HMAP->coff = 0; HMAP->soff = 1; + } else { + /* + * If number of lines HMAP->lno (top line) spans + * changed due to, say reformatting, and now is + * fewer than HMAP->soff, reset so the line is + * redrawn at the top of the screen. + */ + cnt = vs_screens(sp, HMAP->lno, NULL); + if (cnt < HMAP->soff) + HMAP->soff = 1; } /* If we fail, just punt. */ for (p = HMAP, cnt = sp->t_rows; --cnt; ++p) -- 2.11.4.GIT