From: Michael D. Lowis Date: Mon, 10 Sep 2018 20:05:46 +0000 (-0400) Subject: dirty fix for view_limitrows. Definitely needs to be refactored X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=40ce501f1a6f4bec1c8a067d07859e9e7108ae63;p=projs%2Ftide.git dirty fix for view_limitrows. Definitely needs to be refactored --- diff --git a/lib/view.c b/lib/view.c index 13e4939..ca44e2e 100644 --- a/lib/view.c +++ b/lib/view.c @@ -100,12 +100,17 @@ 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') nrows++; - 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); + } else { + if (xpos <= view->width) + off = buf_byrune(&(view->buffer), off, RIGHT); + else + xpos = 0, nrows++; + } } + printf("rows: %lu\n", nrows); return nrows; }