yuku / textcomplete

Autocomplete for HTMLTextAreaElement and more.

Home Page:https://yuku.takahashi.coffee/textcomplete/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong index passed to match function

bruian opened this issue · comments

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;
}