Flush stdout before killpg so terminal restore codes survive

sys.stdout is line-buffered on a tty, and fill3's terminal restore
context managers (alternate_buffer, mouse_tracking, title) only write
escape sequences without newlines. killpg(SIGKILL) killed the process
before those buffered codes were flushed, leaving the terminal stuck
in the alternate buffer with mouse tracking on. Flush first.
This commit is contained in:
Andrew Hamilton 2026-08-03 11:10:33 +10:00
parent 36a07813e7
commit 53474b2bcb

View file

@ -1081,6 +1081,7 @@ async def main(title, root_path, worker_count=None, editor_command=None, theme=N
screen.save()
if sys.stdout.isatty() and (os.getpgrp() == os.getpid()
or os.getpgrp() == os.getppid()):
sys.stdout.flush()
os.killpg(os.getpgrp(), signal.SIGKILL)