aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2022-01-21 17:26:54 +0100
committerOmar Polo <op@omarpolo.com>2022-01-21 17:26:54 +0100
commit6d5348f32514004ad33d27ece8dec68ffed9b209 (patch)
tree5a7ddec25386a1d53b563d72e59e3bcadfac38f8
parent2ef8fcaedd93b1a56d0940ddd58a43a6d6c321f0 (diff)
downloadtelescope-main.tar.gz
telescope-main.tar.bz2
set_scroll_position: further semplificationsHEADmain
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.
-rw-r--r--ui.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/ui.c b/ui.c
index c7c260c..ea9e15f 100644
--- a/ui.c
+++ b/ui.c
@@ -130,7 +130,7 @@ set_scroll_position(struct tab *tab, size_t top, size_t cur)
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_t cur)
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