Console.Clear() does not clear Console, just skips lines

I think my problem is best describe by showing you an example input and the corresponding output:

Console.WriteLine("This");
Console.WriteLine("is");
Console.WriteLine("some");
Console.WriteLine("text");

Console.Clear();

Console.WriteLine("This");
Console.WriteLine("is");
Console.WriteLine("some");
Console.WriteLine("new");
Console.WriteLine("text");

The output is the following:

I guess, this is not normal? How can I fix it?

4 comments
Comment actions Permalink

Possibly a known issue:

https://youtrack.jetbrains.com/issue/RIDER-66804#focus=Comments-27-5258548.0-0

Solution is to launch external console when testing.

0
Comment actions Permalink

I did use both, internal and external console, both with the same result. I also updated Riders to the nightly build using the Toolbox, which did not helper either.

0
Comment actions Permalink

I just tried your code and it worked fine for me on Linux.  I also tried this:

Console.WriteLine("Hello, World!");

for (int index = 0; index < 10; index++)
{
    Console.WriteLine(index.ToString());
}

Console.Clear();

for (int index = 10; index < 20; index++)
{
    Console.WriteLine(index.ToString());
}

And while the Rider console doesn't even show any space after Console.Clear(), the external console looks fine.

Note in Linux I don't think it clears the console buffer like in windows, but rather just resets the caret to the upper left corner, maybe your problem has something to do with it not properly resetting to the upper left corner.

0
Comment actions Permalink

Fost 99, if it does reproduce with Use external console in Run Configuration, then it seems to be related to the following known issue: https://github.com/dotnet/runtime/issues/28355

0

Please sign in to leave a comment.