commit fcfb26c37e218d01b0cfb8b960b7b186f9ee285e from: Stefan Sperling via: Thomas Adam date: Fri May 26 19:18:47 2023 UTC fix 'tog log' display regression with long reference lists When the terminal becomes smaller horizontally we did not properly account for remaining columns and the log message of a commit could overflow into the next line, garbling the display. commit - 3785c9e59d01b1954a7478be06382ca98f097bb4 commit + fcfb26c37e218d01b0cfb8b960b7b186f9ee285e blob - 7dce0c320b49b2d997e618585f826a965d125d27 blob + 9e373e9ea71a56438d94e21186e9dff1d7e6d312 --- tog/tog.c +++ tog/tog.c @@ -2509,7 +2509,7 @@ draw_commit(struct tog_view *view, struct got_commit_o if (refs_str) { char *newlogmsg; wchar_t *ws; - + /* * The length of this wide-char sub-string will be * needed later for colorization. @@ -2544,11 +2544,12 @@ draw_commit(struct tog_view *view, struct got_commit_o wattr_on(view->window, COLOR_PAIR(tc->colorpair), NULL); waddnwstr(view->window, &wlogmsg[scrollx], - wrefstr_len - scrollx); + MIN(logmsg_width, wrefstr_len - scrollx)); if (tc) wattr_off(view->window, COLOR_PAIR(tc->colorpair), NULL); - waddwstr(view->window, &wlogmsg[wrefstr_len]); + if (col + MIN(logmsg_width, wrefstr_len - scrollx) < avail) + waddwstr(view->window, &wlogmsg[wrefstr_len]); } else waddwstr(view->window, &wlogmsg[scrollx]); col += MAX(logmsg_width, 0);