fix(display): use spaces instead of ANSI \033[K in print_above() for prompt_toolkit compat

print_above() used \033[K (erase-to-end-of-line) to clear the spinner
line before printing text above it. This causes garbled escape codes when
prompt_toolkit's patch_stdout is active in CLI mode.

Switched to the same spaces-based clearing approach used by stop() —
overwrite with blanks, then carriage return back to start of line.

Updated test assertion to match the new clearing method.
This commit is contained in:
teknium1 2026-02-28 23:19:23 -08:00
parent dd69f16c3e
commit 4ec386cc72
2 changed files with 6 additions and 3 deletions

View file

@ -46,7 +46,7 @@ class TestPrintAbove:
spinner.print_above("tool line")
output = buf.getvalue()
assert "tool line" in output
assert "\r\033[K" in output # Should start with line clear
assert "\r" in output # Should start with carriage return to clear spinner line
def test_print_above_uses_captured_stdout(self):
"""print_above should use self._out, not sys.stdout.