sindresorhus / ansi-escapes

ANSI escape codes for manipulating the terminal
MIT License
485 stars 44 forks source link

`clearTerminal` not working on Windows 10 w/ GitBash #21

Closed stramel closed 4 years ago

stramel commented 4 years ago

Snowpack is using this package to clear the terminal and it is causing my Windows 10 Git Bash terminal to spam output.

Here is the gist of the output: https://gist.github.com/stramel/66bed75cb5900c3a87ba1f5e6e942e74

Here is the usage: https://github.com/pikapkg/snowpack/blob/2e010bb862d3d8349b6254cbfc9f8d9d98bb0c6a/src/commands/paint.ts#L53

Also, related discussion on snowpack's discussion board: https://www.pika.dev/npm/snowpack/discuss/191

Qix- commented 4 years ago

Not much we can do about this, really. Unles the emulator that comes with Git Bash has a special character to clear the terminal, there's nothing we can really do on our end to fix this.

Keep in mind that TTY escape codes are very archaic and haven't seen much progress since the 90's (maybe earlier). This is kind of an unfortunate side effect of that.

One thing to make sure of is that you're scrolled all the way down to the very bottom of the terminal (not just the output, but make sure the scroll bar, if any, hits the very bottom of the "track"). A common side effect of applications that "clear" or "update" the terminal + scrolling upward = repeated or sporadic output, such as what you're describing.

Sorry I couldn't give you a better answer. I'm going to go ahead and close this as there's nothing actionable unless it's found Git Bash has proprietary escape codes and gives us a means of doing terminal detection.

If this is really, really bothering you and you would like to see a fix, you can open a ticket with Git Bash directly.

stramel commented 4 years ago

@Qix- This what CRA used to clear the screen for Git Bash on Windows. Testing locally, it seems to generate significantly better output.

https://github.com/facebook/create-react-app/pull/2071 https://github.com/facebook/jest/pull/5251

Not sure if there would be interest in doing something similar for this lib?