Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProgressBar.WriteLine doesn't show recent messages #79

Open
gqqnbig opened this issue Feb 6, 2021 · 4 comments
Open

ProgressBar.WriteLine doesn't show recent messages #79

gqqnbig opened this issue Feb 6, 2021 · 4 comments

Comments

@gqqnbig
Copy link

gqqnbig commented Feb 6, 2021

I will use a built-in test case as an example. I expect the built-in test case to work out of box.

Steps to reproduce:

clone this project and checkout c28355f

apply this patch

--- src/ShellProgressBar.Example/Examples/PersistMessageExample.cs: c28355ff	2021-02-06 11:26:24.000000000 +0800
+++ src/ShellProgressBar.Example/Examples/PersistMessageExample.cs: 	2021-02-06 11:22:24.000000000 +0800
@@ -46,12 +46,12 @@
 		private static void LongRunningTask(FixedDurationBar bar)
 		{
 			for (var i = 0; i < 1_000_000; i++)
 			{
 				bar.Message = $"{i} events";
 				if (bar.IsCompleted) break;
-				if (i % 500 == 0) bar.WriteLine($"Report {i} to console above the progressbar");
+				if (i % 5 == 0) bar.WriteLine($"Report {i} to console above the progressbar");
 				Thread.Sleep(1);
 			}
 		}
 	}
 }

Expected:

I expect to see
Report 15 to console above the progressbar
up to
Report 1000 to console above the progressbar
,etc. while the progrss bar is running.

Actual

Latest messages don't show. See the screenshot.
progress

@gqqnbig
Copy link
Author

gqqnbig commented Feb 6, 2021

I tried to make a fix but ProgressBar.cs has way few comments that I can't figure out the purpose of variables.

@TweakBox
Copy link

I noticed that as time would go on, the progress bar would slowly "eat" up the spaces above it and it would overwrite anything that's above it

@Mpdreamz
Copy link
Owner

Mpdreamz commented Jun 7, 2022

I can't replicate this on Linux, won't be able to test this on Windows for a while.

@EddyToo
Copy link

EddyToo commented Dec 6, 2022

(Replaces previous comment)

This problem occurs (only) on windows because the windows console allows a BufferHeight > WindowHeight (causing a vertical scrollbar to appear). This also means that Console.WindowsTop will change when scrolling starts and that Console.CursorTop will be between Console.WindowTop and Console.WindowTop+Console.WindowHeight

On other platforms setting the Bufferheight will throw an exception. Getting it will return WindowHeight

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

No branches or pull requests

4 participants