Skip to content

Commit 1aed1a5

Browse files
szedergitster
authored andcommitted
progress: avoid empty line when breaking the progress line
Since commit 545dc34 (progress: break too long progress bar lines, 2019-04-12) when splitting a too long progress line, sometimes it looks as if a superfluous empty line were added between the title line and the counters. To make sure that the previously displayed progress line is completely covered up when writing the new, shorter title line, we calculate how many characters need to be overwritten with spaces. Alas, this calculation doesn't account for the newline character at the end of the new title line, and resulted in printing one more space than strictly necessary. This extra space character doesn't matter, if the length of the previous progress line was shorter than the width of the terminal. However, if the previous line matched the terminal width, then this extra space made the new line longer, effectively adding that empty line after the title line. Fix this off-by-one to avoid that spurious empty line. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 545dc34 commit 1aed1a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

progress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void display(struct progress *progress, uint64_t n, const char *done)
127127
(int) clear_len, eol);
128128
} else if (!done && cols < progress_line_len) {
129129
clear_len = progress->title_len + 1 < cols ?
130-
cols - progress->title_len : 0;
130+
cols - progress->title_len - 1 : 0;
131131
fprintf(stderr, "%s:%*s\n %s%s",
132132
progress->title, (int) clear_len, "",
133133
counters_sb->buf, eol);

0 commit comments

Comments
 (0)