mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 03:43:19 +00:00
Use break in a loop
This commit is contained in:
parent
3a6814f3b0
commit
85811a50d9
1 changed files with 3 additions and 2 deletions
|
@ -196,8 +196,9 @@ def truncate_to_len(string: str, width: int) -> str:
|
|||
|
||||
for char in string:
|
||||
cur_len += 2 if unicodedata.east_asian_width(char) in "WF" else 1
|
||||
if cur_len < width:
|
||||
out_string += char
|
||||
out_string += char
|
||||
if cur_len >= width:
|
||||
break
|
||||
return out_string
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue