Skip to content

Conversation

@Kelebek1
Copy link

Windows Terminal doesn't clear its buffers properly and scrolling is all screwy. Diffs don't open with new buffers, and it's possible to scroll up to view previous console output. This workaround forces a clear which clears that out. If there's a better way/place to do this, let me know.

# Janky hack to clear its scrollback buffer until it's fixed
clear_proc = subprocess.Popen(
["echo", "-en", "\"\e[3J\""]
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Popen() starts a new process that runs asynchronously; we'd need to wait for it to finish if we do this (clear_proc.wait() or subprocess.run()/similar). Does it work if you instead do

        sys.stdout.write("\x1b7[3J\"")
        sys.stdout.flush()

?

There is a os.system("tput reset") further down which is similar to this btw, but I guess it doesn't help for whatever reason (and it doesn't do anything for the very first less call).

Copy link
Author

@Kelebek1 Kelebek1 Mar 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stdout writes don't work unfortunately. It looks like tput reset does work as well, but the issue I have with that is that it clears all of your previous console output after closing the diff, but it's nice to keep previous commands visible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants