commander-rb / commander

The complete solution for Ruby command-line executables
MIT License
823 stars 74 forks source link

Fix negative Highline wrap #15

Closed toolmantim closed 9 years ago

toolmantim commented 9 years ago

If a terminal reports it's screen width as < 5, wrap_at could become negative causing Highline to enter an infinite loop whilst wrapping.

This makes sure we don't set negative wrap_at values by ensuring the terminal screen width at least 5.

It also cleans up the duplicated code.

ggilder commented 9 years ago

Thanks, good catch! I think we could actually set the threshold much higher; it doesn't make much sense to wrap at 1 character when the width is 6, for instance. What do you think about turning wrapping off below 40?

toolmantim commented 9 years ago

Makes sense to me! I'll update it to be >= 40?

ggilder commented 9 years ago

Sounds good!

toolmantim commented 9 years ago

Cool, updated to 40. I also discovered we should be using Highline#output_cols, which already does the rescue and what-not for the terminal size calculation. Tested and pushed.

toolmantim commented 9 years ago

:heart::tada:

ggilder commented 9 years ago

Thank you! Just cut a new version, 4.3.5, to include this patch. :zap:

toolmantim commented 9 years ago

Boom! And that worked a treat. Thanks for the :zap:'y release!