8000 Fix width computation in Progress Formatter · mxr/python-prompt-toolkit@02fa485 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02fa485

Browse files
Marc Chevalierjonathanslenders
authored andcommitted
Fix width computation in Progress Formatter
It used to print with replacement field {:>3} but compute width with {}. Consequently, short numbers (<= 2 digits) were computed to have length less than or equal to 2 wut printed as 3 characters, and so, not displayed.
1 parent 67e742d commit 02fa485

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

prompt_toolkit/shortcuts/progress_bar/formatters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def format(self, progress_bar, progress, width):
168168
total=progress.total or '?')
169169

170170
def get_width(self, progress_bar):
171-
all_lengths = [len('{0}'.format(c.total)) for c in progress_bar.counters]
171+
all_lengths = [len('{0:>3}'.format(c.total)) for c in progress_bar.counters]
172172
all_lengths.append(1)
173173
return D.exact(max(all_lengths) * 2 + 1)
174174

0 commit comments

Comments
 (0)
0