From edd650fd4a763a0856229594d2851bb38f9bd750 Mon Sep 17 00:00:00 2001 From: Mustitz Date: Tue, 2 Sep 2025 10:12:20 +0300 Subject: [PATCH 1/2] Fix TypeError in select_graphic_rendition - Add private parameter to select_graphic_rendition() method signature - Handle private=True parameter by returning early (no-op for private SGR sequences) --- pyte/screens.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyte/screens.py b/pyte/screens.py index 384542f..1907617 100644 --- a/pyte/screens.py +++ b/pyte/screens.py @@ -971,11 +971,15 @@ def alignment_display(self) -> None: for x in range(self.columns): self.buffer[y][x] = self.buffer[y][x]._replace(data="E") - def select_graphic_rendition(self, *attrs: int) -> None: + def select_graphic_rendition(self, *attrs: int, private: bool = False) -> None: """Set display attributes. :param list attrs: a list of display attributes to set. + :param bool private: if True, ignore the SGR sequence (private sequences are not supported). """ + if private: + return + replace = {} # Fast path for resetting all attributes. From 48d43d4c623c81e179a20fba3db3bac140ef11ea Mon Sep 17 00:00:00 2001 From: Mustitz Date: Tue, 2 Sep 2025 10:11:30 +0300 Subject: [PATCH 2/2] Add test for private SGR sequence handling - Add test_private_sgr_sequence_ignored() to verify Vim 9.0+ modifyOtherKeys query is ignored - Test ensures private SGR sequences don't affect screen display, modes, or cursor state --- tests/test_screen.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_screen.py b/tests/test_screen.py index 7626f61..d7a7a1d 100644 --- a/tests/test_screen.py +++ b/tests/test_screen.py @@ -1583,3 +1583,24 @@ def test_screen_set_icon_name_title(): screen.set_title(text) assert screen.title == text + + +def test_private_sgr_sequence_ignored(): + def cursor_state(cursor): + return (cursor.x, cursor.y, cursor.attrs, cursor.hidden) + + screen = pyte.HistoryScreen(2, 2) + stream = pyte.ByteStream(screen) + + # Capture initial state + display = screen.display + mode = screen.mode.copy() + cursor = cursor_state(screen.cursor) + + # Vim 9.0+ sends this to query modifyOtherKeys capability - should be ignored + stream.feed(b'\x1b[?4m') + + # Verify nothing changed + assert screen.display == display + assert screen.mode == mode + assert cursor_state(screen.cursor) == cursor