Skip to content

Conversation

@mustitz
Copy link
Contributor

@mustitz mustitz commented Sep 1, 2025

Fixes #202

  • 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 Outdated
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, **kwargs: Any) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be private: bool = False so that we don't allow arbitrary kwargs here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're absolutely right. Using private: bool = False is much better than **kwargs.

I used the existing **kwargs pattern as a reference from other methods in the codebase, but you're correct that explicit parameters are better. I noticed that set_mode(), reset_mode(), erase_in_display(), and report_device_attributes() also use the same pattern for the private parameter. Should I refactor those methods for consistency as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the rest as is and only change select_graphic_rendition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@mustitz mustitz force-pushed the fix-sgr-private-parameter branch from 808df45 to eaa831d Compare September 1, 2025 18:17
Copy link
Collaborator

@superbobry superbobry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@superbobry
Copy link
Collaborator

Would you mind adding a test for this to avoid regressions in the future?

- Add private parameter to select_graphic_rendition() method signature
- Handle private=True parameter by returning early (no-op for private SGR sequences)
- 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
@mustitz mustitz force-pushed the fix-sgr-private-parameter branch from eaa831d to 48d43d4 Compare September 2, 2025 07:15
@mustitz
Copy link
Contributor Author

mustitz commented Sep 2, 2025

Would you mind adding a test for this to avoid regressions in the future?

Done

@superbobry superbobry merged commit 1397bad into selectel:master Sep 2, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError in select_graphic_rendition handler (argument private) from SGR sequence ESC[?4m

2 participants