Open thorstenkampe opened 7 years ago
So the root cause is how carriage return behaves after the terminal autowraps.
The simple solution I went with was to overload writeln() to wrap the printed line in escapes to disable and then re-enable autowrap:
print('\x1b[?7l' + line + '\x1b[?7h', end='', file=self.file)
This however had the undesirable side-effect of truncating the line in a non-obvious way (fine as an individual fix, but not for default behaviour).
Options that I'd imagine would be nicer:
terminal_width - len(''.join([message, self.bar_prefix, self.bar_suffix, suffix]))
to set the bar width for that update. This would resulting in fluctuating bar widths though due to changing suffices etc (which is why the original issue only started at the tenth iteration).@shannonfenn truncating the line sounds better as a default behavior then the terminal going crazy and emitting lots of progress bar lines.
I was investigating the effect this bug has on pip
and found it is probably the root cause of issues like https://github.com/pypa/pip/issues/6101. Along with affecting anyone who tries to use pip install
on a small terminal :)
Is there some way I can help push this towards a fix?
facing the same issue in Termux (android / smartphone terminal), noticed that depending on the terminal size the "newline" bug appears.
Hi,
the following code triggers a wrapping bug in connection with the terminal size:
This is the output on a 87x40 terminal (the bug "starts" at value 10):
This is the output on a maximized terminal: