From 3be81ba62a0cdaa0e0936d9ec5b17b0a69a12610 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Thu, 10 Dec 2015 10:12:40 +0100 Subject: [PATCH] word hints should be generated on first call --- qutebrowser/browser/hints.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 93cb84621..e88ec6378 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -138,9 +138,6 @@ class HintManager(QObject): Target.spawn: "Spawn command via hint", } - with open(os.path.join(standarddir.config(), "hints")) as hintfile: - HINT_WORDS = [hint.rstrip() for hint in hintfile] - mouse_event = pyqtSignal('QMouseEvent') start_hinting = pyqtSignal(usertypes.ClickTarget) stop_hinting = pyqtSignal() @@ -155,6 +152,12 @@ class HintManager(QObject): window=win_id) mode_manager.left.connect(self.on_mode_left) + def _get_word_hints(self, words=[]): + if not words: + with open(os.path.join(standarddir.config(), "hints")) as hintfile: + words.extend(hint.rstrip() for hint in hintfile) + return words + def _get_text(self): """Get a hint text based on the current context.""" text = self.HINT_TEXTS[self._context.target] @@ -204,7 +207,7 @@ class HintManager(QObject): A list of hint strings, in the same order as the elements. """ if config.get('hints', 'mode') == 'words': - return HINT_WORDS[:len(elems)] + return self._get_word_hints()[:len(elems)] if config.get('hints', 'mode') == 'number': chars = '0123456789' else: