{"thread":{"id":"51128","subject":"[PATCH] progress: avoid empty line when breaking the progress line","startedAt":"2019-05-19T17:51:09Z","lastAt":"2019-05-19T17:51:09Z","messageCount":1,"participants":["SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"375883","messageId":"20190519144546.9978-1-szeder.dev@gmail.com","threadId":"51128","inReplyTo":null,"subject":"[PATCH] progress: avoid empty line when breaking the progress line","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-05-19T14:45:46Z","receivedAt":"2019-05-19T17:51:09Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Since commit 545dc345eb (progress: break too long progress bar lines,\n2019-04-12) when splitting a too long progress line, sometimes it\nlooks as if a superfluous empty line were added between the title\nline and the counters.\n\nTo make sure that the previously displayed progress line is completely\ncovered up when writing the new, shorter title line, we calculate how\nmany characters need to be overwritten with spaces.  Alas, this\ncalculation doesn't account for the newline character at the end of\nthe new title line, and resulted in printing one more space than\nstrictly necessary.  This extra space character doesn't matter, if the\nlength of the previous progress line was shorter than the width of the\nterminal.  However, if the previous line matched the terminal width,\nthen this extra space made the new line longer, effectively adding\nthat empty line after the title line.\n\nFix this off-by-one to avoid that spurious empty line.\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n progress.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/progress.c b/progress.c\nindex 2d8022a622..a4da26c2aa 100644\n--- a/progress.c\n+++ b/progress.c\n@@ -127,7 +127,7 @@ static void display(struct progress *progress, uint64_t n, const char *done)\n \t\t\t\t\t(int) clear_len, eol);\n \t\t\t} else if (!done && cols < progress_line_len) {\n \t\t\t\tclear_len = progress->title_len + 1 < cols ?\n-\t\t\t\t\t    cols - progress->title_len : 0;\n+\t\t\t\t\t    cols - progress->title_len - 1 : 0;\n \t\t\t\tfprintf(stderr, \"%s:%*s\\n  %s%s\",\n \t\t\t\t\tprogress->title, (int) clear_len, \"\",\n \t\t\t\t\tcounters_sb->buf, eol);\n-- \n2.22.0.rc1.424.g15834b9bb1\n\n"}]}