commit 95f298c8fcfd1e75a66ebaff9cf572eb958337ff
parent f4a0ba1296512f8bbc3ccd74e8c02b81cd6c21ea
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Thu, 16 Jul 2020 13:38:57 +0200
fix-up position if needed
Change the order of checking if the current position becomes invalid.
A case where the position became incorrect, to reproduce:
* Toggle only showing feeds with new items ('t' keybind).
* Go to the last position in the feeds pane ('G' keybind).
* Wait until the last entries become "old" or are updated in some way, such as
waiting a day.
* Reload all feeds ('R' keybind).
* The position in the feeds pane is out-of-bounds and also cannot be changed
anymore.
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sfeed_curses.c b/sfeed_curses.c
@@ -632,14 +632,14 @@ pane_setpos(struct pane *p, off_t pos)
{
off_t prev;
- if (pos == p->pos)
- return; /* no change */
- if (!p->nrows)
- return; /* invalid */
if (pos < 0)
pos = 0; /* clamp */
+ if (!p->nrows)
+ return; /* invalid */
if (pos >= p->nrows)
pos = p->nrows - 1; /* clamp */
+ if (pos == p->pos)
+ return; /* no change */
/* is on different scroll region? mark dirty */
if (((p->pos - (p->pos % p->height)) / p->height) !=
@@ -1236,6 +1236,10 @@ updatesidebar(int onlynew)
}
p->nrows = nrows;
p->width = width;
+ if (!p->nrows)
+ p->pos = 0;
+ else if (p->pos >= p->nrows)
+ p->pos = p->nrows - 1;
p->dirty = 1;
}