#334: Wait only for first matched rule; regression: always show arrows

This commit is contained in:
nvbn
2015-09-01 14:34:41 +03:00
parent 5d74344994
commit 61937e9e8f
4 changed files with 8 additions and 34 deletions
+4 -15
View File
@@ -62,21 +62,15 @@ class SortedCorrectedCommandsSequence(object):
def __init__(self, commands, settings):
self._settings = settings
self._commands = commands
self._cached = self._get_first_two_unique()
self._cached = self._realise_first()
self._realised = False
def _get_first_two_unique(self):
"""Returns first two unique commands."""
def _realise_first(self):
try:
first = next(self._commands)
return [next(self._commands)]
except StopIteration:
return []
for command in self._commands:
if command != first:
return [first, command]
return [first]
def _remove_duplicates(self, corrected_commands):
"""Removes low-priority duplicates."""
commands = {command
@@ -87,8 +81,7 @@ class SortedCorrectedCommandsSequence(object):
def _realise(self):
"""Realises generator, removes duplicates and sorts commands."""
commands = self._cached[1:] + list(self._commands)
commands = self._remove_duplicates(commands)
commands = self._remove_duplicates(self._commands)
self._cached = [self._cached[0]] + sorted(
commands, key=lambda corrected_command: corrected_command.priority)
self._realised = True
@@ -112,7 +105,3 @@ class SortedCorrectedCommandsSequence(object):
if not self._realised:
self._realise()
return iter(self._cached)
@property
def is_multiple(self):
return len(self._cached) > 1