From 40ef9746ca902105ed5d90e98a2abe854ccfa870 Mon Sep 17 00:00:00 2001 From: karlch Date: Fri, 26 Jul 2024 16:51:32 +0200 Subject: [PATCH] Fix binding of configparser comment chars Neither semicolon `;` nor the number symbol `#` could be bound as they were parsed by configparser as a comment. Fixed by allowing to bind these via and instead. --- tests/unit/gui/test_eventhandler.py | 1 + vimiv/gui/eventhandler.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/unit/gui/test_eventhandler.py b/tests/unit/gui/test_eventhandler.py index 38a848d2..cdfe1124 100644 --- a/tests/unit/gui/test_eventhandler.py +++ b/tests/unit/gui/test_eventhandler.py @@ -53,6 +53,7 @@ def test_temp_key_storage_clears_text(storage, qtbot): ), (Qt.Key.Key_Colon, Qt.KeyboardModifier.NoModifier, ":", ("",)), (Qt.Key.Key_Equal, Qt.KeyboardModifier.NoModifier, "=", ("",)), + (Qt.Key.Key_Semicolon, Qt.KeyboardModifier.NoModifier, ";", ("",)), ], ) def test_keyevent_to_sequence(qtkey, modifier, keyname, expected): diff --git a/vimiv/gui/eventhandler.py b/vimiv/gui/eventhandler.py index 24a2feb8..b105410d 100644 --- a/vimiv/gui/eventhandler.py +++ b/vimiv/gui/eventhandler.py @@ -275,9 +275,11 @@ def _get_base_keysequence(event: QKeyEvent) -> SequenceT: Qt.Key.Key_PageDown: "", Qt.Key.Key_Delete: "", } - separator_keys = { + configparser_keys = { Qt.Key.Key_Colon: "", Qt.Key.Key_Equal: "", + Qt.Key.Key_Semicolon: "", + Qt.Key.Key_NumberSign: "", } if event.key() in special_keys: # Parse shift here as the key does not support it otherwise @@ -285,8 +287,8 @@ def _get_base_keysequence(event: QKeyEvent) -> SequenceT: if event.modifiers() & Qt.KeyboardModifier.ShiftModifier: return "", text return (text,) - if event.key() in separator_keys: # Required as configparser crashes otherwise - return (separator_keys[event.key()],) # type: ignore + if event.key() in configparser_keys: # Required as configparser crashes otherwise + return (configparser_keys[event.key()],) # type: ignore if event.text().isprintable(): return (event.text(),) return (QKeySequence(event.key()).toString().lower(),)