1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-06 16:27:11 -04:00

[utils] write_string: Workaround newline issue in conhost

On windows `conhost`, when `WINDOWS_VT_MODE` is enabled, `\n` is not
actually sent if the window is exactly the length of printed line,
and the line does not end with a white-space character. So the
line-break disappears when resizing the window.

Fixes #1863
This commit is contained in:
pukkandan
2022-04-28 19:11:04 +05:30
parent 0a5a191a2a
commit 59f943cd50
2 changed files with 5 additions and 1 deletions

View File

@@ -1851,6 +1851,10 @@ def write_string(s, out=None, encoding=None):
assert isinstance(s, str)
out = out or sys.stderr
from .compat import WINDOWS_VT_MODE # Must be imported locally
if WINDOWS_VT_MODE:
s = s.replace('\n', ' \n')
if 'b' in getattr(out, 'mode', ''):
byt = s.encode(encoding or preferredencoding(), 'ignore')
out.write(byt)