未验证 提交 59f943cd 编写于 作者: P pukkandan

[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
上级 0a5a191a
......@@ -3580,7 +3580,7 @@ def print_debug_header(self):
def get_encoding(stream):
ret = str(getattr(stream, 'encoding', 'missing (%s)' % type(stream).__name__))
if not supports_terminal_sequences(stream):
from .compat import WINDOWS_VT_MODE
from .compat import WINDOWS_VT_MODE # Must be imported locally
ret += ' (No VT)' if WINDOWS_VT_MODE is False else ' (No ANSI)'
return ret
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册