Skip to content

Commit 55cde3e

Browse files
Fix line wrapping in patch_stdout on Windows.
Enable autowrap before writing data to the output in `patch_stdout`. We enable/disable VT terminal processing during every `flush()` of the Windows Output implementation, but it turns out that this causes the autowrap flag to be reset each time. Because of this, we have to enable autowrap each time before writing.
1 parent 857af14 commit 55cde3e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/prompt_toolkit/patch_stdout.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ def _write_and_flush(
203203
"""
204204

205205
def write_and_flush() -> None:
206+
# Ensure that autowrap is enabled before calling `write`.
207+
# XXX: On Windows, the `Windows10_Output` enables/disables VT
208+
# terminal processing for every flush. It turns out that this
209+
# causes autowrap to be reset (disabled) after each flush. So,
210+
# we have to enable it again before writing text.
211+
self._output.enable_autowrap()
212+
206213
if self.raw:
207214
self._output.write_raw(text)
208215
else:

0 commit comments

Comments
 (0)