Display bug when number of lines exceeds lines of terminal
placeybordeaux opened this issue · 8 comments
This can be observed by creating a tiny terminal window and running demo.sh
It might be tricky to handle all of the edge-cases involved here. In addition to the issue you've pointed out, there's also:
- too narrow of a terminal causes tasks to overwrite lower ones
- resizing the terminal while running causes chaos
I'm really not sure how to robustly handle these situations without resorting to a fully-fledged library like curses...and I'd rather avoid the dependency.
😩
Thoughts?
Detecting if the window is too small to show all of them and simply going with a smaller status line type thing might be a nice way to keep it simple, but not provide false information.
Could be as simple as branching on tput lines < #jobs
Does that sound reasonable both technically and from a UI point of view?
An interesting idea! Were you envisioning something super-compact like a sparkline? Maybe with a little extra info about which task finished most recently?
I don't have a strong opinion, I just wanted to use concurrent to run well over 300 tasks with some basic and bounded level of concurrency and was surprised to see it 'start' on #400 or so. I think it's completely reasonable to fall back to whatever basic level of support you think is reasonable when someone has a window smaller than the number of jobs.
I'll try some various things with a huge number of tasks and see what works best!
I have an experimental branch with an alternate "compact" display for when there are more tasks scheduled than terminal rows. I've also made some performance improvements, as handling a large number of tasks was super slow. It's still not blazing fast, but this is bash after all 😉
Give it a try here: https://github.com/themattrix/bash-concurrent/tree/many-tasks
I've also added a demo for this: ./demo.sh many
I'd still like to tweak the look a bit since it's kind of ugly. Feedback would be much appreciated!
Just took a look at it, I think that's a reasonable approach, it might be nice to have info on what recently completed or what is in progress, but that is certainly nicer than it displaying incorrect information.
I made a few more tweaks (like adding a recently-completed line), and felt it was good enough to merge it to master. I'll close this issue, but feel free to continue discussion here or open another issue if you discover any bugs!