Embed pagination fixing (pt2) (#3248)

* I hate embeds

* changelog

* until splitting the fields, ensure a field

* make this work, from a user perspective
This commit is contained in:
Michael H 2020-01-09 10:50:04 -05:00 committed by Kowlin
parent 9698baf6e7
commit ed3b4e5b29
2 changed files with 9 additions and 6 deletions

View File

@ -0,0 +1 @@
fix a buggy first page of paginated help

View File

@ -277,16 +277,18 @@ class RedHelpFormatter:
ret = [] ret = []
current_count = 0 current_count = 0
for f in fields: for i, f in enumerate(fields):
f_len = len(f.value) + len(f.name) f_len = len(f.value) + len(f.name)
if curr_group and (f_len + current_count > max_chars):
# Commands start at the 1st index of fields, i < 2 is a hacky workaround for now
if not current_count or f_len + current_count > max_chars or i < 2:
current_count += f_len
curr_group.append(f)
elif curr_group:
ret.append(curr_group) ret.append(curr_group)
curr_group = []
current_count = 0 current_count = 0
curr_group.append(f) curr_group = [f]
current_count += f_len
else: else:
# Loop cleanup here
if curr_group: if curr_group:
ret.append(curr_group) ret.append(curr_group)