diff --git a/diff.py b/diff.py index e657437..3f60e86 100755 --- a/diff.py +++ b/diff.py @@ -1446,6 +1446,13 @@ def run_less(self) -> "Tuple[subprocess.Popen[bytes], subprocess.Popen[bytes]]": header_lines = [header] if header else [] output = "\n".join(header_lines + diff_lines[args.skip_lines :]) + # Windows Terminal does not handle buffers properly + # Janky hack to clear its scrollback buffer until it's fixed + clear_proc = subprocess.Popen( + ["echo", "-en", "\"\e[3J\""] + ) + clear_proc.wait() + # Pipe the output through 'tail' and only then to less, to ensure the # write call doesn't block. ('tail' has to buffer all its input before # it starts writing.) This also means we don't have to deal with pipe