Clear _empty_item_idx correctly.

This commit is contained in:
Florian Bruhin 2014-06-03 09:51:20 +02:00
parent f2c60c01ae
commit e741744f1d

View File

@ -79,6 +79,7 @@ class Command(MinimalLineEdit):
self.cursor_part = 0 self.cursor_part = 0
self.history = History() self.history = History()
self._validator = _CommandValidator(self) self._validator = _CommandValidator(self)
self._empty_item_idx = None
self.setValidator(self._validator) self.setValidator(self._validator)
self.textEdited.connect(self.on_text_edited) self.textEdited.connect(self.on_text_edited)
self.cursorPositionChanged.connect(self._update_cursor_part) self.cursorPositionChanged.connect(self._update_cursor_part)
@ -123,7 +124,6 @@ class Command(MinimalLineEdit):
else: else:
logger.debug("Cursor not between spaces") logger.debug("Cursor not between spaces")
spaces = False spaces = False
self._empty_item_idx = None
cursor_pos -= len(self.prefix) cursor_pos -= len(self.prefix)
for i, part in enumerate(self.parts): for i, part in enumerate(self.parts):
logger.debug("part {}, len {}, pos {}".format(i, len(part), logger.debug("part {}, len {}, pos {}".format(i, len(part),
@ -139,6 +139,8 @@ class Command(MinimalLineEdit):
logger.debug("Cursor between spaces -> queueing empty " logger.debug("Cursor between spaces -> queueing empty "
"element at {}.".format(i)) "element at {}.".format(i))
self._empty_item_idx = i self._empty_item_idx = i
else:
self._empty_item_idx = None
return return
cursor_pos -= (len(part) + 1) # FIXME are spaces always 1 char? cursor_pos -= (len(part) + 1) # FIXME are spaces always 1 char?
return None return None