This commit is contained in:
Kovid Goyal 2023-05-22 12:12:47 +05:30
parent 4f44527eb1
commit a2a0848bb1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -85,7 +85,13 @@ def wrap_button_text(text, max_len=MAX_TEXT_LENGTH):
broken = True
else:
ans = word
if not broken:
if broken:
prefix, suffix = ans.split('\n', 1)
if len(suffix) > len(prefix) and len(suffix) > MAX_TEXT_LENGTH and len(prefix) < MAX_TEXT_LENGTH and suffix.count(' ') > 1:
word, rest = suffix.split(' ', 1)
if len(word) + len(prefix) <= len(rest):
ans = prefix + ' ' + word + '\n' + rest
else:
if ' ' in ans:
ans = '\n'.join(ans.split(' ', 1))
elif '/' in ans: