Ignore completion updates while completing

This commit is contained in:
Florian Bruhin 2014-06-02 16:12:03 +02:00
parent 1928add992
commit 749e330383
2 changed files with 8 additions and 1 deletions

View File

@ -52,6 +52,7 @@ class CompletionView(QTreeView):
COLUMN_WIDTHS: A list of column widths, in percent. COLUMN_WIDTHS: A list of column widths, in percent.
Attributes: Attributes:
_ignore_change: Whether to ignore the next completion update.
_model: The currently active filter model. _model: The currently active filter model.
_lastmodel: The model set in the last iteration. _lastmodel: The model set in the last iteration.
_models: dict of available completion models. _models: dict of available completion models.
@ -104,6 +105,7 @@ class CompletionView(QTreeView):
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent) super().__init__(parent)
self._enabled = config.get('completion', 'show') self._enabled = config.get('completion', 'show')
self._ignore_change = False
self._model = None self._model = None
self._lastmodel = None self._lastmodel = None
self._models = { self._models = {
@ -292,6 +294,10 @@ class CompletionView(QTreeView):
text: The new text text: The new text
cursor_part: The part the cursor is currently over. cursor_part: The part the cursor is currently over.
""" """
if self._ignore_change:
logger.debug("Ignoring completion update")
return
if prefix != ':': if prefix != ':':
# This is a search or gibberish, so we don't need to complete # This is a search or gibberish, so we don't need to complete
# anything (yet) # anything (yet)
@ -361,7 +367,9 @@ class CompletionView(QTreeView):
if indexes: if indexes:
data = self._model.data(indexes[0]) data = self._model.data(indexes[0])
if data is not None: if data is not None:
self._ignore_change = True
self.change_completed_part.emit(data) self.change_completed_part.emit(data)
self._ignore_change = False
super().selectionChanged(selected, deselected) super().selectionChanged(selected, deselected)
def resizeEvent(self, e): def resizeEvent(self, e):

View File

@ -115,7 +115,6 @@ class Command(MinimalLineEdit):
# foo| bar # foo| bar
self.cursor_part = i self.cursor_part = i
if old_cursor_part != i: if old_cursor_part != i:
# FIXME do we really want to emit this here?
self.update_completion.emit(self.prefix, self.parts, self.update_completion.emit(self.prefix, self.parts,
self.cursor_part) self.cursor_part)
return return