use object state in stead of class state to store hint words
This commit is contained in:
parent
aaad8588b6
commit
86828930a2
@ -149,12 +149,13 @@ class HintManager(QObject):
|
|||||||
self._win_id = win_id
|
self._win_id = win_id
|
||||||
self._tab_id = tab_id
|
self._tab_id = tab_id
|
||||||
self._context = None
|
self._context = None
|
||||||
|
self._words = [] # initialized on first word hint use
|
||||||
mode_manager = objreg.get('mode-manager', scope='window',
|
mode_manager = objreg.get('mode-manager', scope='window',
|
||||||
window=win_id)
|
window=win_id)
|
||||||
mode_manager.left.connect(self.on_mode_left)
|
mode_manager.left.connect(self.on_mode_left)
|
||||||
|
|
||||||
def _get_word_hints(self, words=[]):
|
def _get_word_hints(self):
|
||||||
if not words:
|
if not self._words:
|
||||||
with open("/usr/share/dict/words") as wordfile:
|
with open("/usr/share/dict/words") as wordfile:
|
||||||
alphabet = set(string.ascii_lowercase)
|
alphabet = set(string.ascii_lowercase)
|
||||||
hints = set()
|
hints = set()
|
||||||
@ -165,8 +166,8 @@ class HintManager(QObject):
|
|||||||
for i in range(len(word)):
|
for i in range(len(word)):
|
||||||
hints.discard(word[:i+1])
|
hints.discard(word[:i+1])
|
||||||
hints.add(word)
|
hints.add(word)
|
||||||
words.extend(hints)
|
self._words.extend(hints)
|
||||||
return words
|
return self._words
|
||||||
|
|
||||||
def _get_text(self):
|
def _get_text(self):
|
||||||
"""Get a hint text based on the current context."""
|
"""Get a hint text based on the current context."""
|
||||||
|
Loading…
Reference in New Issue
Block a user