yuku / textcomplete

Autocomplete for HTMLTextAreaElement and more.
https://yuku.takahashi.coffee/textcomplete/
MIT License
1.74k stars 303 forks source link

Wrong index passed to match function #339

Closed bruian closed 3 years ago

bruian commented 3 years ago

Hello my friend. I seem to have encountered a bug in the following function.


execute(beforeCursor, callback) {
        const match = this.matchWithContext(beforeCursor);
        if (!match)
            return false;

When the index is zero, then JS assumes that the value is false and instead of passing 0 index, the default value is passed.

        const term = match[this.props.index || exports.DEFAULT_INDEX];
        this.search(term, (results) => {
            callback(results.map((result) => new SearchResult_1.SearchResult(result, term, this)));
        }, match);
        return true;
}