Skip to content

Commit 9a9b37d

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 8ca2ba3 commit 9a9b37d

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

@@ -1037,7 +1038,7 @@ def sentinel_keys():
10371038
for item in items:
10381039
for entry in lst:
10391040
result = formatter.format(entry["fmt"], item)
1040-
width = 0 if result in empty else len(result)
1041+
width = 0 if result in empty else wcswidth(result)
10411042
if width > entry["maxwidth"]:
10421043
entry["maxwidth"] = width
10431044
if width > entry["width"]:

0 commit comments

Comments
 (0)