diff options
author | Joel Bradshaw <cincodenada@gmail.com> | 2018-12-24 00:10:30 -0800 |
---|---|---|
committer | Joel Bradshaw <cincodenada@gmail.com> | 2018-12-24 00:37:18 -0800 |
commit | c2c64d0623df3121f69185220ffc57af10c423d4 (patch) | |
tree | 1638cb0822cbdc338c9a172ec703a86416b4b138 | |
parent | 065ece5283d7f582498fae04b438cc6a1f97dc38 (diff) | |
download | qutebrowser-c2c64d0623df3121f69185220ffc57af10c423d4.tar.gz qutebrowser-c2c64d0623df3121f69185220ffc57af10c423d4.zip |
Never mind, early return is what we want
Also, add default variable so old code (e.g. tests) is okay, and
update keycode for the Chinese character even though it doesn't
really matter to the test
-rw-r--r-- | qutebrowser/keyinput/keyutils.py | 10 | ||||
-rw-r--r-- | tests/unit/keyinput/test_keyutils.py | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py index b59b2c83a..8870dd7c6 100644 --- a/qutebrowser/keyinput/keyutils.py +++ b/qutebrowser/keyinput/keyutils.py @@ -308,7 +308,7 @@ class KeyInfo: key = attr.ib() modifiers = attr.ib() - key_text = attr.ib() + key_text = attr.ib(default="") @classmethod def from_event(cls, e): @@ -324,9 +324,9 @@ class KeyInfo: # These are Unicode characters (such as emoji) if _is_extended_unicode(self.key): _check_valid_utf8(self.key_text, self.key) - key_string = self.key_text - else: - key_string = _key_to_string(self.key) + return self.key_text + + key_string = _key_to_string(self.key) modifiers = int(self.modifiers) @@ -426,7 +426,7 @@ class KeySequence: key = int(key_and_modifiers) & ~Qt.KeyboardModifierMask modifiers = Qt.KeyboardModifiers(int(key_and_modifiers) & Qt.KeyboardModifierMask) - yield KeyInfo(key=key, modifiers=modifiers, key_text="") + yield KeyInfo(key=key, modifiers=modifiers) def __repr__(self): return utils.get_repr(self, keys=str(self)) diff --git a/tests/unit/keyinput/test_keyutils.py b/tests/unit/keyinput/test_keyutils.py index af80e00ea..1e5350989 100644 --- a/tests/unit/keyinput/test_keyutils.py +++ b/tests/unit/keyinput/test_keyutils.py @@ -167,7 +167,7 @@ def test_key_info_str(key, modifiers, expected): def test_extended_unicode(): assert str(keyutils.KeyInfo(0xd83c, Qt.NoModifier, "🏻")) == "🏻" - assert str(keyutils.KeyInfo(0xd83c, Qt.NoModifier, "𩷶")) == "𩷶" + assert str(keyutils.KeyInfo(0xd867, Qt.NoModifier, "𩷶")) == "𩷶" @pytest.mark.parametrize('keystr, expected', [ ('foo', "Could not parse 'foo': error"), |