Skip to content

Commit

Permalink
Fix #368 - swallow zero-width modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbrittain committed Sep 17, 2023
1 parent d4c9fe7 commit 077dff6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -3,12 +3,13 @@ CHANGE HISTORY

LATEST
------
- Dropped support for Python 2, Python 3.9 or above is now required.
- Added support for ColouredText titles in MultiColumnLIstBox.
- Added gutter option to Layout.
- Added speed option to Sprite.
- Fixed bug where moving focus between Frames resulted in no current focus.
- Fixed internal state of RadioButton values to be consistent with selection.
- Dropped support for Python 2, Python 3.9 or above is now required.
- Fixed handling of zero width modifiers.

1.14.0
------
Expand Down
5 changes: 5 additions & 0 deletions asciimatics/screen.py
Expand Up @@ -626,6 +626,11 @@ def print_at(self, text, x, y, colour=7, attr=0, bg=0, transparent=False):
if x + i + j + width > self.width:
return

# Handle modifier glyphs - just delete them for now.
if width == 0:
j -= 1
continue

# Now handle the update.
if c != " " or not transparent:
# Fix up orphaned double-width glyphs that we've just bisected.
Expand Down
8 changes: 8 additions & 0 deletions tests/test_screen.py
Expand Up @@ -918,6 +918,14 @@ def test_cjk_glyphs_overwrite(self):
# twice, reflecting their extra width.
self.assert_line_equals(screen, "x你你確確 ", y=1, length=6)

def test_zero_width(self):
"""
Check that zero width modifiers are ignored.
"""
screen = Screen.open(unicode_aware=True)
screen.print_at("Xx🛡️🍀🍀xX", 0, 0)
self.assert_line_equals(screen, "Xx🛡🍀🍀🍀🍀xX", length=9)

def test_save_signal_state(self):
"""Tests that the signal state class works properly.
Expand Down

0 comments on commit 077dff6

Please sign in to comment.