From 85811a50d979cb8ce8529d388570156b941e9ede Mon Sep 17 00:00:00 2001 From: Paul Nameless Date: Mon, 27 Jul 2020 19:51:21 +0800 Subject: [PATCH] Use break in a loop --- tg/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tg/utils.py b/tg/utils.py index 9120f18..934899f 100644 --- a/tg/utils.py +++ b/tg/utils.py @@ -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