Use break in a loop

This commit is contained in:
Paul Nameless 2020-07-27 19:51:21 +08:00
parent 3a6814f3b0
commit 85811a50d9

View file

@ -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