commit 02bce7e239bf6bbd35c2d61a6306abd7ab820c2c from: Stefan Sperling via: Thomas Adam date: Thu Jun 23 14:09:34 2022 UTC fix horizontal scrolling bug in the blame view ok op@, jamsek commit - 84227eb1cd472aee3db29eed97367db85b2480e9 commit + 02bce7e239bf6bbd35c2d61a6306abd7ab820c2c blob - 3b27329a02abb5e83fe928c5c27ec186ccc0d01e blob + 316c79d23a88ac31766f9199ae4d7ee7295bbc4f --- tog/tog.c +++ tog/tog.c @@ -4199,7 +4199,7 @@ draw_blame(struct tog_view *view) struct tog_blame *blame = &s->blame; regmatch_t *regmatch = &view->regmatch; const struct got_error *err; - int lineno = 0, nprinted = 0; + int lineno = 0, nprinted = 0, i; char *line = NULL; size_t linesize = 0; ssize_t linelen; @@ -4341,14 +4341,18 @@ draw_blame(struct tog_view *view) } else { err = format_line(&wline, &width, line, view->x + view->ncols - 9, 9, 1); - if (!err && view->x < width - 1) { - waddwstr(view->window, wline + view->x); - width += 9; + if (err) { + free(line); + return err; + } + if (view->x < width) { + waddwstr(view->window, wline + view->x); + for (i = 0; i < view->x; i++) + width -= wcwidth(wline[i]); } + width += 9; free(wline); wline = NULL; - if (err) - return err; } if (width <= view->ncols - 1)