-
Notifications
You must be signed in to change notification settings - Fork 57
Description
Describe the bug
Emoji marker display works out of the box, and normally emojis are displayed correctly, with most taking up the width of 2 ASCII characters each (I'm on GNU bash, version 5.0.16(1)-release (x86_64-apple-darwin17.7.0)).
However, when the marker column of a report contains emoji markers but no ASCII-markers (or column header label) wider than 1 character, then the required column width is incorrectly calculated to be 1 character wide, which does not leave enough space for the emoji markers to be displayed.
(I've only tested this on a small number of emojis but presumably the bug also applies to all other non-width-1 Unicode characters/symbols.)
To Reproduce
Open any report using the following marker config
[marker]
enabled = True
header_label=
require_color = False
# just override all (multi-character) defaults with a single emoji to be able to reproduce the bug on most reports
active.label =💡
blocked.label =💡
blocking.label =💡
completed.label =💡
deleted.label =💡
due.label =💡
#due.today.label =💡
keyword.label =💡
overdue.label =💡
project.label =💡
project.none.label =💡
recurring.label =💡
scheduled.label =💡
tag.label =💡
tag.none.label =💡
Expected behavior
Emoji markers should be displayed by allocating a wide enough marker column based on a correct calculation of the marker width (which might have to take into account properties of the console/font set).
Suggested fix
The mis-calculation happens in line 38 here, which assumes that every String character is exactly one display character wide:
Lines 34 to 41 in 8fdebc3
| def add_label(self, color, label, width, text_markup): | |
| if self.color_required(color) or not label: | |
| return width, text_markup | |
| width += len(label) | |
| text_markup += [(color, label)] | |
| return width, text_markup | |
Python-Curses doesn't seem to provide a way to perform a correct width calculation of Unicode symbols, so solving this might require recourse to an external library dependency (in particular https://github.com/jquast/wcwidth)