commit 6d5348f32514004ad33d27ece8dec68ffed9b209 from: Omar Polo date: Fri Jan 21 16:26:54 2022 UTC set_scroll_position: further semplifications Simplify it even further. There's no need to keep the curfound variable *at all*: if we end the loop, current_line is not found. commit - 2ef8fcaedd93b1a56d0940ddd58a43a6d6c321f0 commit + 6d5348f32514004ad33d27ece8dec68ffed9b209 blob - c7c260c7ee8da4cf04fe468f2a7fc52eac4f45fd blob + ea9e15f47d366cdbcbcd3288ee9124aeb1f67d58 --- ui.c +++ ui.c @@ -130,7 +130,7 @@ set_scroll_position(struct tab *tab, size_t top, size_ struct line *last; struct vline *vl; size_t i = 0; - int topfound = 0, curfound = 0; + int topfound = 0; last = TAILQ_FIRST(&tab->buffer.page.head); TAILQ_FOREACH(vl, &tab->buffer.head, vlines) { @@ -144,19 +144,16 @@ set_scroll_position(struct tab *tab, size_t top, size_ tab->buffer.top_line = vl; } - if (!curfound && i == cur) { + if (i == cur) { tab->buffer.current_line = vl; return; } } - if (!topfound) { + if (!topfound) 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; + tab->buffer.current_line = tab->buffer.top_line; } void