diff --git a/tqdm/std.py b/tqdm/std.py index 56d0628d..54336230 100644 --- a/tqdm/std.py +++ b/tqdm/std.py @@ -490,7 +490,7 @@ class tqdm(Comparable): return nobar full_bar = Bar( 0, - max(1, ncols - len(RE_ANSI.sub('', nobar))) if ncols else 10, + max(1, ncols - _text_width(RE_ANSI.sub('', nobar))) if ncols else 10, charset=Bar.BLANK) return bar_format.format(bar=full_bar, **format_dict) else: diff --git a/tqdm/utils.py b/tqdm/utils.py index ee8a8769..17b6aba6 100644 --- a/tqdm/utils.py +++ b/tqdm/utils.py @@ -286,6 +286,7 @@ def _term_move_up(): # pragma: no cover def _text_width(s): # pragma: no cover + # TODO consider using wcswidth third-party package for 0-width characters try: from unicodedata import east_asian_width except ImportError: