aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-04-28 19:11:04 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-04-28 20:04:40 +0530
commit59f943cd5097e9bdbc3cb3e6b5675e43d369341a (patch)
tree4fe2b81ef6a16c21827f2939da2c687aac0dde78 /yt_dlp/utils.py
parent0a5a191a2a33e3b305aaf684576b7129ba5173a0 (diff)
downloadhypervideo-pre-59f943cd5097e9bdbc3cb3e6b5675e43d369341a.tar.lz
hypervideo-pre-59f943cd5097e9bdbc3cb3e6b5675e43d369341a.tar.xz
hypervideo-pre-59f943cd5097e9bdbc3cb3e6b5675e43d369341a.zip
[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
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 0171394fc..7faee62ac 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -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)