[Help] Group Fields respect page_char_limit (#2281)

It would groups the cogs until it is **greater** than the set `page_char_limit` in helpset. This leads to inconsistent page sizes when a large cog was appended to something barely under the limit.

I think this commit will reign in the weirdness by adjusting the secondary grouping to aim for **less than** `page_char_limit` grouping.
This commit is contained in:
bobloy 2019-02-06 02:59:54 -05:00 committed by Toby Harradine
parent dc8e61cbe5
commit 7c404082f8

View File

@ -215,10 +215,10 @@ class Help(dpy_formatter.HelpFormatter):
curr_group = []
ret = []
for f in fields:
curr_group.append(f)
if sum(len(f.value) for f in curr_group) > max_chars:
if sum(len(f2.value) for f2 in curr_group) + len(f.value) > max_chars and curr_group:
ret.append(curr_group)
curr_group = []
curr_group.append(f)
if len(curr_group) > 0:
ret.append(curr_group)