Fixed crash bug. Wide characters were sometimes causing an index out of range error. Now they are just treated as spaces.

This commit is contained in:
Storm Dragon
2026-08-17 02:26:04 -04:00
parent 93a2745065
commit 68462d00cb
3 changed files with 38 additions and 1 deletions
+1 -1
View File
@@ -4,5 +4,5 @@
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributors.
version = "2026.08.14"
version = "2026.08.17"
code_name = "testing"
@@ -49,6 +49,23 @@ class PTYConstants:
class FenrirScreen(pyte.Screen):
@property
def display(self):
def render(line):
skip_stub = False
for x in range(self.columns):
if skip_stub:
skip_stub = False
continue
char = line[x].data
if not char:
yield " "
continue
skip_stub = pyte.screens.wcwidth(char[0]) == 2
yield char
return ["".join(render(self.buffer[y])) for y in range(self.lines)]
def set_margins(self, *args, **kwargs):
kwargs.pop("private", None)
super(FenrirScreen, self).set_margins(*args, **kwargs)
+20
View File
@@ -39,6 +39,26 @@ def test_private_sgr_sequence_from_fullscreen_apps_does_not_crash():
assert screen["text"].splitlines()[0] == "X "
@pytest.mark.unit
def test_overwritten_wide_character_stub_renders_as_space():
terminal = Terminal(4, 1, DummyProcessInput())
terminal.feed("\rX".encode())
screen = terminal.get_screen_content()
assert screen["text"] == "X "
@pytest.mark.unit
def test_wide_character_and_stub_keep_terminal_width():
terminal = Terminal(4, 1, DummyProcessInput())
terminal.feed("".encode())
screen = terminal.get_screen_content()
assert screen["text"] == ""
@pytest.mark.unit
def test_optional_float_setting_uses_default_when_missing():
settings_manager = type(