From 678b4d54af99ce7f02bcf2f2b7febf5a3c2a6137 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 24 Mar 2014 11:37:41 +0100 Subject: [PATCH] Refactor completion chosing --- qutebrowser/widgets/completion.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index cd790faca..193be23a2 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -156,23 +156,20 @@ class CompletionView(QTreeView): parts: The command chunks to get a completion for. """ - model = None if len(parts) == 1: - model = 'command' - else: - # try to delegate to the command - try: - completions = cmdutils.cmd_dict[parts[0]].completion - logging.debug('completions: {}'.format(completions)) - if completions is None: - model = None - else: - model = completions[len(parts) - 2] - except KeyError: - logging.debug("No completions for '{}'".format(parts[0])) - model = None - # FIXME: if this fails, what do we do? - return model + return 'command' + # try to delegate to the command + try: + completions = cmdutils.cmd_dict[parts[0]].completion + except KeyError: + return None + logging.debug('completions: {}'.format(completions)) + if completions is None: + return None + try: + return completions[len(parts) - 2] + except IndexError: + return None def set_model(self, model): """Switch completion to a new model.