'Return a list of words that match the prefix before the cursor.'

def getwords(self):

    word = self.getprevword()
    if (not word):
        return []
    before = self.text.get('1.0', 'insert    wordstart')
    wbefore = re.findall((('\\b' + word) + '\\w+\\b'), before)
    del before
    after = self.text.get('insert    wordend', 'end')
    wafter = re.findall((('\\b' + word) + '\\w+\\b'), after)
    del after
    if ((not wbefore) and (not wafter)):
        return []
    words = []
    dict = {}
    wbefore.reverse()
    for w in wbefore:
        if dict.get(w):
            continue
        words.append(w)
        dict[w] = w
    for w in wafter:
        if dict.get(w):
            continue
        words.append(w)
        dict[w] = w
    words.append(word)
    return words
