From 56d29a1b5f9f40776a5e7d24705d43b6e5ec730d Mon Sep 17 00:00:00 2001 From: Luca Benci Date: Sat, 21 Oct 2017 23:20:37 +0200 Subject: [PATCH] Avoid scheduling spurious completion updates Instead of setting `_ignore_change` to `True` before calling `_change_completed_part` we just stop `_cmd` from emitting `update_completion`. This has the nice side-effect that when writing a complete command `_ignore_change` was set to `True` regardless, and thus hitting space would not update the completion view. Now, hitting space will (as always) schedule a completion update that now will not be incorrectly ignored --- qutebrowser/completion/completer.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py index eaf74f959..0840d6396 100644 --- a/qutebrowser/completion/completer.py +++ b/qutebrowser/completion/completer.py @@ -186,8 +186,6 @@ class Completer(QObject): # keep offering completions (see issue #1519) self._ignore_change = True else: - log.completion.debug("Will ignore next completion update.") - self._ignore_change = True self._change_completed_part(text, before, after) @pyqtSlot() @@ -284,7 +282,20 @@ class Completer(QObject): # pad with a space if quick-completing the last entry text += ' ' log.completion.debug("setting text = '{}', pos = {}".format(text, pos)) + + # generally, we don't want to let self._cmd emit cursorPositionChanged, + # because that'll schedule a completion update. That happens when + # tabbing through the completions, and we want to change the command + # text but we also want to keep the original completion list for the + # command the user manually entered. The exception is when we're + # immediately completing, in which case we *do* want to update the + # completion view so that we can start completing the next part + if not immediate: + self._cmd.blockSignals(True) + self._cmd.setText(text) self._cmd.setCursorPosition(pos) self._cmd.setFocus() + + self._cmd.blockSignals(False) self._cmd.show_cmd.emit()