GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
I was running into situations where ProgressBar would work correctly most of the time, but then fall into an infinite loop. And I think I've tracked it down to the recursive implementation of #show_tty.
While I know that show_tty is trying to make the bar fit the width of the screen, I'll be honest--that code is too tangled for me to figure out what thinking went into it. But I do know that when I did a pen-and-paper trace through it, I could see an infinite loop happening if width, line.width, and @terminal_width started out being the same value.
So I edited it into a standard loop using break and next instead, and I gave it a limited number of iterations (10, a completely arbitrary value). I ran the test and it still seems to work, except I saw a new blank line in there that concerns me. Still, I'd rather have that than an infinite loop grinding my work to a halt any day. :-)
Reimplemented show_tty as a non-recursive loop.
@L2G, thanks for this but I think I'm going to hold off on it till v1.0 is released. I'm antsy about this big of a change with no tests. Once I get that pushed to the development branch, could you take a look and see if the same problem exists?
Ok, development has been pushed. Feel free to take a look if you'd like. If you do, I'd appreciate any feedback you may have.
Sorry for the delayed reply. I will try to take a look at this tonight or tomorrow night.
@L2G, I'm going to close this for now. If you get a chance to reimplement another TTY solution, I'd love a pull request. Thanks!