From 1d2cf3b648a1f6a0bb4cb61c9aa142086920d24e Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Wed, 21 Sep 2016 07:08:34 -0400 Subject: [PATCH] Completer: don't try to partition search. Exit before trying to partition if the command prefix is not ':'. Resolves #1969: 'TypeError with refactored completion when searching for command' --- qutebrowser/completion/completer.py | 10 +++++----- tests/unit/completion/test_completer.py | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py index ac2a84e6b..21f7b99ce 100644 --- a/qutebrowser/completion/completer.py +++ b/qutebrowser/completion/completer.py @@ -226,11 +226,6 @@ class Completer(QObject): @pyqtSlot() def _update_completion(self): """Check if completions are available and activate them.""" - before_cursor, pattern, after_cursor = self._partition() - - log.completion.debug("Updating completion: {} {} {}".format( - before_cursor, pattern, after_cursor)) - if self._ignore_change: log.completion.debug("Ignoring completion update because " "ignore_change is True.") @@ -247,6 +242,11 @@ class Completer(QObject): completion.set_model(None) return + before_cursor, pattern, after_cursor = self._partition() + + log.completion.debug("Updating completion: {} {} {}".format( + before_cursor, pattern, after_cursor)) + pattern = pattern.strip("'\"") model = self._get_new_completion(before_cursor, pattern) diff --git a/tests/unit/completion/test_completer.py b/tests/unit/completion/test_completer.py index 9601af57d..7e9fdbb48 100644 --- a/tests/unit/completion/test_completer.py +++ b/tests/unit/completion/test_completer.py @@ -180,6 +180,7 @@ def _set_cmd_prompt(cmd, txt): (':set -t -p |', usertypes.Completion.section, ''), (':open -- |', None, ''), (':gibberish nonesense |', None, ''), + ('/:help|', None, ''), ]) def test_update_completion(txt, kind, pattern, status_command_stub, completer_obj, completion_widget_stub):