diff --git a/Changelog.md b/Changelog.md index 7ac826b..ec452ef 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,9 @@ Below is a complete listing of changes for each revision of HighLine. +### 3.1.2 / 2025-01-05 +* PR #278 - Prevent ArgumentError for #col_count_calculate when items exceed 80 chars (@davidjkling, @justintsteele) + ### 3.1.1 / 2024-08-18 * PR #276 - Update #say to always flush the output after a #puts (@blipper) * PR #274 / I #273 (@costa) diff --git a/lib/highline/list_renderer.rb b/lib/highline/list_renderer.rb index 5446ea5..cbd161e 100644 --- a/lib/highline/list_renderer.rb +++ b/lib/highline/list_renderer.rb @@ -236,8 +236,8 @@ def row_join_str_size end def col_count_calculate - (line_size_limit + row_join_str_size) / - (items_max_length + row_join_str_size) + result = (line_size_limit + row_join_str_size) / (items_max_length + row_join_str_size) + result == 0 ? 1 : result end def col_count diff --git a/lib/highline/version.rb b/lib/highline/version.rb index 833ce3f..10851f6 100644 --- a/lib/highline/version.rb +++ b/lib/highline/version.rb @@ -2,5 +2,5 @@ class HighLine # The version of the installed library. - VERSION = "3.1.1".freeze + VERSION = "3.1.2".freeze end diff --git a/test/test_highline.rb b/test/test_highline.rb index bd420c5..c9a4883 100755 --- a/test/test_highline.rb +++ b/test/test_highline.rb @@ -1024,6 +1024,17 @@ def test_lists @output.truncate(@output.rewind) + colums_of_81 = ["1234567890" * (81 / 10) + "1"] + + @terminal.say("<%= list(#{colums_of_81.inspect}, :columns_down) %>") + assert_equal("1234567890123456789" \ + "01234567890123456789" \ + "01234567890123456789" \ + "0123456789012345678901\n", + @output.string) + + @output.truncate(@output.rewind) + @terminal.say("<%= list(#{digits.inspect}, :columns_across, 3) %>") assert_equal("Zero One Two \n" \ "Three Four Five \n" \