From 8e2afd92c494d83c0c9305d15b26733d5810eafe Mon Sep 17 00:00:00 2001 From: Maide Date: Thu, 25 Mar 2021 13:44:11 +0000 Subject: [PATCH 1/2] Janky hack --- diff.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/diff.py b/diff.py index e657437..c1f5eb0 100755 --- a/diff.py +++ b/diff.py @@ -1446,6 +1446,12 @@ 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\""] + ) + # 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 From 8802de35033a23f62949f911177e10fcaf0188e2 Mon Sep 17 00:00:00 2001 From: Maide Date: Thu, 25 Mar 2021 14:46:05 +0000 Subject: [PATCH 2/2] Wait --- diff.py | 1 + 1 file changed, 1 insertion(+) diff --git a/diff.py b/diff.py index c1f5eb0..3f60e86 100755 --- a/diff.py +++ b/diff.py @@ -1451,6 +1451,7 @@ def run_less(self) -> "Tuple[subprocess.Popen[bytes], subprocess.Popen[bytes]]": 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