fix: cli: don't crash multicol with few strings
When there are only few, short strs and width is large, then the div operation in itemspercol would return zero, triggering and error in chunksOf. This fix makes numcols have always at least as many entries as strs, filling one line.
This commit is contained in:
parent
fa70f160ae
commit
4b43e63a89
@ -277,7 +277,7 @@ multicol _ [] = []
|
||||
multicol width strs =
|
||||
let
|
||||
maxwidth = maximum' $ map length strs
|
||||
numcols = width `div` (maxwidth+2)
|
||||
numcols = min (length strs) (width `div` (maxwidth+2))
|
||||
itemspercol = length strs `div` numcols
|
||||
colitems = chunksOf itemspercol strs
|
||||
cols = map unlines colitems
|
||||
|
||||
Loading…
Reference in New Issue
Block a user