Fix for underscore in user dictionary causing KeyError

This commit is contained in:
James Fitzgerald 2022-06-30 16:55:06 -04:00 committed by xs5871
parent 0e58bdc343
commit 0392aa74e2

View File

@ -68,13 +68,18 @@ class TextReplacement(Module):
to_substitute = []
substitution = []
for char in entry:
key_code = getattr(KC, char.upper())
if char == "_":
key_code = KC.LSHIFT(KC.MINUS)
else:
key_code = getattr(KC, char.upper())
shifted = char.isupper() or key_code.has_modifiers == {2}
to_substitute.append(Character(key_code, shifted))
for char in dictionary[entry]:
key_code = getattr(KC, char.upper())
if char == "_":
key_code = KC.LSHIFT(KC.MINUS)
else:
key_code = getattr(KC, char.upper())
shifted = char.isupper() or key_code.has_modifiers == {2}
shifted = char.isupper()
substitution.append(Character(key_code, shifted))
self._rules.append(Rule(Phrase(to_substitute), Phrase(substitution)))