fixed when new hints are prefixes of existing

good thing I used this some days before any merging
This commit is contained in:
Felix Van der Jeugt 2015-12-18 09:45:58 +01:00
parent 1dfcf99d22
commit 766a94a539

View File

@ -268,16 +268,15 @@ class HintManager(QObject):
if not match: continue if not match: continue
yield candidate[match.start():match.end()].lower() yield candidate[match.start():match.end()].lower()
def is_prefix(hint, existing): def any_prefix(hint, existing):
return set(hint[:i+1] for i in range(len(hint))) & set(existing) return any(hint.startswith(e) or e.startswith(hint) for e in existing)
def first_good_hint(new, existing): def first_good_hint(new, existing):
for hint in new: for hint in new:
# some none's # some none's
if not hint: continue if not hint: continue
if len(hint) < 3: continue if len(hint) < 3: continue
# not a prefix of an existing hint if any_prefix(hint, existing): continue
if set(hint[:i+1] for i in range(len(hint))) & set(existing): continue
return hint return hint
hints = [] hints = []