You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Console.Clear() does not clear buffers on macOS #8260
In a C# Console Application on .net 6 and higher, (unknown if this affects previous versions!), using Console.Clear() does not clear the terminal buffers.
Clears the console buffer and corresponding console window of display information.
I.e.: calls reset or an equivalent to printf "\033c" on non-Windows terminals.
In fact, calling Console.Clear() does not clear the buffers; the previously written text is still clearly visible when scrolling up.
Instead, it seems Console.Clear() flushes N lines to the buffer similar to scrolling down a page.
Configuration
This code has been run on .net6.0 and .net7.0 on macOS Ventura; I don't know if this bug affects previous versions.
Architecture: AARCH64.
I assume this bug affects many (if not all) of the non-Windows terminals. Haven't tested this theory however!
Other information
Screenshot of the behaviour:
The code executed when clear is typed to the console:
Console.Clear();
AFAICT there are no real (portable) workarounds, because the Console class does not provide access to the buffer on all platforms.
Using
Console.Write("\x1bc");// the hex equivalent of "\033c" (octal)
also does not clear the console, instead it prints Ƽ on macOS.
Of course one could always write thousands upon thousands of lines of code in an attempt to run into the line limit and clear the terminal that way, but that's not a feasable solution.
Activity
liveans commentedon Mar 6, 2023
Hello,
This is duplicate of dotnet/runtime#28355.
However, you can use this code as workaround:
SimonCahill commentedon Mar 6, 2023
I'll give that a try, thanks!
If that solves the issue, I'll close this one.
This should really be fixed though.