From 3c780e1d10ff9d389f282d1dbceae76f2f19d65f Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Fri, 26 May 2006 03:46:03 +0000 Subject: [PATCH] fix edit_redraw() breakage git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3571 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- src/winio.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/winio.c b/src/winio.c index 195ee370..73a44a13 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2817,19 +2817,25 @@ void edit_redraw(const filestruct *old_current, size_t old_pww) #ifndef NANO_TINY /* If the mark is on, update all the lines between old_current - * and the old last line of the edit window. */ + * and either the old first line or old last line (depending on + * whether we've scrolled up or down) of the edit window. */ if (openfile->mark_set) { - ssize_t old_last_lineno = (old_edittop->lineno + - editwinrows <= openfile->filebot->lineno) ? - old_edittop->lineno + editwinrows : - openfile->filebot->lineno; + ssize_t old_lineno; + + if (old_edittop->lineno < openfile->edittop->lineno) + old_lineno = old_edittop->lineno; + else + old_lineno = (old_edittop->lineno + editwinrows <= + openfile->filebot->lineno) ? + old_edittop->lineno + editwinrows : + openfile->filebot->lineno; foo = old_current; - while (foo->lineno != old_last_lineno) { + while (foo->lineno != old_lineno) { update_line(foo, 0); - foo = (foo->lineno > old_last_lineno) ? foo->prev : + foo = (foo->lineno > old_lineno) ? foo->prev : foo->next; } } @@ -2861,13 +2867,14 @@ void edit_redraw(const filestruct *old_current, size_t old_pww) edit_scroll(DOWN, nlines); #ifndef NANO_TINY - /* If the mark is on, update all the lines between the old last - * line of the edit window and edittop. */ + /* If the mark is on, update all the lines between the old first + * line or old last line of the edit window (depending on + * whether we've scrolled up or down) and current. */ if (openfile->mark_set) { - while (foo != openfile->edittop) { + while (foo->lineno != openfile->current->lineno) { update_line(foo, 0); - foo = (foo->lineno > openfile->edittop->lineno) ? + foo = (foo->lineno > openfile->current->lineno) ? foo->prev : foo->next; } } -- 2.39.5