From 87b174b4186699c13a770d64af07323969010dc8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 19 Nov 2017 21:07:33 +0100 Subject: [PATCH] Simplify :completion-item-focus --- qutebrowser/completion/completionwidget.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 563da166e..f6983dc4b 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -253,16 +253,13 @@ class CompletionView(QTreeView): selmodel = self.selectionModel() - if which == 'next': - idx = self._next_idx(upwards=False) - elif which == 'prev': - idx = self._next_idx(upwards=True) - elif which == 'next-category': - idx = self._next_category_idx(upwards=False) - elif which == 'prev-category': - idx = self._next_category_idx(upwards=True) - else: # pragma: no cover - raise ValueError("Invalid 'which' value {!r}".format(which)) + indices = { + 'next': self._next_idx(upwards=False), + 'prev': self._next_idx(upwards=True), + 'next-category': self._next_category_idx(upwards=False), + 'prev-category': self._next_category_idx(upwards=True), + } + idx = indices[which] if not idx.isValid(): return