emit keystring_updated iff necessary

This commit is contained in:
Jakub Klinkovský 2016-08-11 15:47:22 +02:00
parent bf0fe3c43b
commit 55a00ab2cf

View File

@ -193,7 +193,7 @@ class BaseKeyParser(QObject):
if match == self.Match.definitive:
self._debug_log("Definitive match for '{}'.".format(
self._keystring))
self._keystring = ''
self.clear_keystring()
self.execute(binding, self.Type.chain, count)
elif match == self.Match.ambiguous:
self._debug_log("Ambiguous match for '{}'.".format(
@ -205,7 +205,7 @@ class BaseKeyParser(QObject):
elif match == self.Match.none:
self._debug_log("Giving up with '{}', no matches".format(
self._keystring))
self._keystring = ''
self.clear_keystring()
else:
raise AssertionError("Invalid match value {!r}".format(match))
return match
@ -271,7 +271,7 @@ class BaseKeyParser(QObject):
time = config.get('input', 'timeout')
if time == 0:
# execute immediately
self._keystring = ''
self.clear_keystring()
self.execute(binding, self.Type.chain, count)
else:
# execute in `time' ms
@ -289,8 +289,7 @@ class BaseKeyParser(QObject):
command/count: As if passed to self.execute()
"""
self._debug_log("Executing delayed command now!")
self._keystring = ''
self.keystring_updated.emit(self._keystring)
self.clear_keystring()
self.execute(command, self.Type.chain, count)
def handle(self, e):
@ -366,6 +365,7 @@ class BaseKeyParser(QObject):
def clear_keystring(self):
"""Clear the currently entered key sequence."""
self._debug_log("discarding keystring '{}'.".format(self._keystring))
self._keystring = ''
self.keystring_updated.emit(self._keystring)
if self._keystring:
self._debug_log("discarding keystring '{}'.".format(self._keystring))
self._keystring = ''
self.keystring_updated.emit(self._keystring)