From a4d7907d104644c62ef114a7e655b40113e2fb5e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 13 Nov 2012 13:59:41 +1100 Subject: [PATCH] vpatch: avoid extra blanks when cursor is in alternate pane. When cursor is in the 'diff' pane of the 'merge' view, the line it is on might not be visible in the main pane. This can cause ugly a_void lines to appear. So make sure there point we refresh is a visible point. Signed-off-by: NeilBrown --- vpatch.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vpatch.c b/vpatch.c index 8b02daf..0784ff5 100644 --- a/vpatch.c +++ b/vpatch.c @@ -1213,7 +1213,7 @@ static void merge_window(struct plist *p, FILE *f, int reverse) struct mpos tpos, /* temp point while drawing lines above and below pos */ toppos, /* pos at top of screen - for page-up */ botpos; /* pos at bottom of screen - for page-down */ - struct mpos vpos, tvpos; + struct mpos vpos, tvpos, vispos; int botrow = 0; int meta = 0, /* mode for multi-key commands- SEARCH or META */ tmeta; @@ -1393,9 +1393,16 @@ static void merge_window(struct plist *p, FILE *f, int reverse) } if (start < 0) start = 0; + vispos = pos; /* visible position - if cursor is in + * alternate pane, pos might not be visible + * in main pane. */ + if (visible(mode, ci.merger[vispos.p.m].type, + vispos.p.s) < 0) + prev_mline(&vispos, fm, fb, fa, ci.merger, mode); + retry: draw_mline(mode, row, start, cols, fm, fb, fa, ci.merger, - pos, (splitrow >= 0 && curs.alt) ? NULL : &curs); + vispos, (splitrow >= 0 && curs.alt) ? NULL : &curs); if (curs.width == 0 && start < curs.col) { /* width == 0 implies it appear after end-of-screen */ start += 8; @@ -1411,7 +1418,8 @@ static void merge_window(struct plist *p, FILE *f, int reverse) } if (refresh) { refresh = 0; - tpos = pos; + + tpos = vispos; for (i = row-1; i >= 1 && tpos.p.m >= 0; ) { prev_mline(&tpos, fm, fb, fa, ci.merger, mode); @@ -1428,7 +1436,7 @@ static void merge_window(struct plist *p, FILE *f, int reverse) toppos = tpos; while (i >= 1) blank(i--, 0, cols, a_void); - tpos = pos; + tpos = vispos; for (i = row; i <= lastrow && ci.merger[tpos.p.m].type != End; ) { draw_mline(mode, i++, start, cols, fm, fb, fa, ci.merger, -- 2.39.5