Skip to content

Commit a4f3786

Browse files
committed
python: consider emojis with expandable width
Problem: The expandable width prefix ("+:") assumes all output characters are 1 character width in size. This may not always be the case, such as with several of the emoji output options. Use wcswidth() instead of len() for calculating output width.
1 parent 31459ee commit a4f3786

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/bindings/python/flux/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from pathlib import Path, PurePosixPath
3131
from string import Formatter
3232
from typing import Mapping
33+
from wcwidth import wcswidth
3334

3435
import yaml
3536

@@ -1027,7 +1028,7 @@ def sentinel_keys():
10271028
for item in items:
10281029
for entry in lst:
10291030
result = formatter.format(entry["fmt"], item)
1030-
width = 0 if result in empty else len(result)
1031+
width = 0 if result in empty else wcswidth(result)
10311032
if width > entry["maxwidth"]:
10321033
entry["maxwidth"] = width
10331034
if width > entry["width"]:

0 commit comments

Comments
 (0)