Skip to content

Commit 40ef974

Browse files
committed
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 <semicolon> and <number> instead.
1 parent af7692b commit 40ef974

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tests/unit/gui/test_eventhandler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def test_temp_key_storage_clears_text(storage, qtbot):
5353
),
5454
(Qt.Key.Key_Colon, Qt.KeyboardModifier.NoModifier, ":", ("<colon>",)),
5555
(Qt.Key.Key_Equal, Qt.KeyboardModifier.NoModifier, "=", ("<equal>",)),
56+
(Qt.Key.Key_Semicolon, Qt.KeyboardModifier.NoModifier, ";", ("<semicolon>",)),
5657
],
5758
)
5859
def test_keyevent_to_sequence(qtkey, modifier, keyname, expected):

vimiv/gui/eventhandler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,20 @@ def _get_base_keysequence(event: QKeyEvent) -> SequenceT:
275275
Qt.Key.Key_PageDown: "<page-down>",
276276
Qt.Key.Key_Delete: "<delete>",
277277
}
278-
separator_keys = {
278+
configparser_keys = {
279279
Qt.Key.Key_Colon: "<colon>",
280280
Qt.Key.Key_Equal: "<equal>",
281+
Qt.Key.Key_Semicolon: "<semicolon>",
282+
Qt.Key.Key_NumberSign: "<number>",
281283
}
282284
if event.key() in special_keys:
283285
# Parse shift here as the key does not support it otherwise
284286
text = special_keys[event.key()] # type: ignore
285287
if event.modifiers() & Qt.KeyboardModifier.ShiftModifier:
286288
return "<shift>", text
287289
return (text,)
288-
if event.key() in separator_keys: # Required as configparser crashes otherwise
289-
return (separator_keys[event.key()],) # type: ignore
290+
if event.key() in configparser_keys: # Required as configparser crashes otherwise
291+
return (configparser_keys[event.key()],) # type: ignore
290292
if event.text().isprintable():
291293
return (event.text(),)
292294
return (QKeySequence(event.key()).toString().lower(),)

0 commit comments

Comments
 (0)