Closed AskAlice closed 3 years ago
LGTM
This change broke the clearing the lines for our CLI https://github.com/planetscale/cli.
I'm not sure what's going on with WSL
, but to fix it, I had to print a new escape sequence:
fmt.Fprint(p.out(), "\033[2K")
The 2K
, means to remove the entire line:
Erases part of the line. If n is 0 (or missing), clear from cursor to the end of the line.
If n is 1, clear from cursor to beginning of the line. If n is 2, clear entire line.
Cursor position does not change.
Esc[K Clear line from cursor right EL0
Esc[0K Clear line from cursor right EL0
Esc[1K Clear line from cursor left EL1
Esc[2K Clear entire line EL2
https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences
I suggest to revert this change or guard it and only call \r
if it detects WSL.
Change reverted and cutting new release. We will need to address this fix again.
detecting the presence of /etc/wsl.conf is the most consistent way, but you can also grep Microsoft /proc/version
Why is \r
causing a line to be deleted? I only know it as Carriage Return
and I wouldn't expect it to delete lines.
seems that in WSL it doesn't actually clear the line when just using \033[K, but it does with \r. In Powershell, however it does clear the line.
this fixes that