From 3f3feaa8e40eaf9167e0bfa4a1d0cd2813536395 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 10 Sep 2018 21:37:31 -0400 Subject: [PATCH] refactored logic for limiting size of tags region --- lib/view.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/view.c b/lib/view.c index ca44e2e..08db6f6 100644 --- a/lib/view.c +++ b/lib/view.c @@ -100,17 +100,15 @@ size_t view_limitrows(View* view, size_t maxrows) { while (nrows < maxrows && off < buf_end(&(view->buffer))) { Rune rune = buf_getrat(&(view->buffer), off); xpos += rune_width(rune, xpos, view->width); - if (rune == '\n') { + /* if the line is full, reset the line and increase row count */ + if (xpos > view->width) { xpos = 0, nrows++; - off = buf_byrune(&(view->buffer), off, RIGHT); } else { - if (xpos <= view->width) - off = buf_byrune(&(view->buffer), off, RIGHT); - else + if (rune == '\n') xpos = 0, nrows++; + off = buf_byrune(&(view->buffer), off, RIGHT); } } - printf("rows: %lu\n", nrows); return nrows; } -- 2.49.0