commit 2ef8fcaedd93b1a56d0940ddd58a43a6d6c321f0 from: Omar Polo date: Fri Jan 21 10:05:48 2022 UTC set_scroll_position: always set current_line There's a small chance we may end up finding the topline but not the current line if a page content is abruptedly changed. While here also drop `curfound = 1': it's a dead assignment since it returns in that conditions. Bug found while reading the output of clang' scan-build, but not thanks to clang. scan-build complained about the `curfound' variable, and by re-reading the code I spotted the missing case. commit - 0e49c9bbcbfef05d5bdf9ad6d851f51fe25c2eaa commit + 2ef8fcaedd93b1a56d0940ddd58a43a6d6c321f0 blob - 463214cefab5e85af06151bd52e9f2946ceb7dd9 blob + c7c260c7ee8da4cf04fe468f2a7fc52eac4f45fd --- ui.c +++ ui.c @@ -145,7 +145,6 @@ set_scroll_position(struct tab *tab, size_t top, size_ } if (!curfound && i == cur) { - curfound = 1; tab->buffer.current_line = vl; return; } @@ -155,6 +154,9 @@ set_scroll_position(struct tab *tab, size_t top, size_ tab->buffer.top_line = TAILQ_FIRST(&tab->buffer.head); tab->buffer.current_line = tab->buffer.top_line; } + + if (!curfound) + tab->buffer.current_line = tab->buffer.top_line; } void