Skip to content

Commit

Permalink
Merge pull request #278 from davidjkling/master
Browse files Browse the repository at this point in the history
bug:🐛 default to 1 for col_count_calculate
  • Loading branch information
abinoam authored Jan 6, 2025
2 parents 8c99b67 + 035ecfc commit b7ddfc3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/highline/list_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/highline/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

class HighLine
# The version of the installed library.
VERSION = "3.1.1".freeze
VERSION = "3.1.2".freeze
end
11 changes: 11 additions & 0 deletions test/test_highline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down

0 comments on commit b7ddfc3

Please sign in to comment.