Search code examples
ace-editor

What is the first parameter for in the callback function of the autocomplete function?


What is the first parameter for in the call back function of the autocomplete handler:

I'm looking at the source here and here and it doesn't describe anything about it.

public function codeCompleter(editor, session, position, prefix, callback):void {
    var row:int = position.row;
    var column:int = position.column;

    if (prefix.length === 0) { 
        callback(null, []);
    }

    var testing:Boolean = false;

    callback(null, [{value:"test"},{value:"test1"},{value:"adding"},{value:"added"}]);

}

Solution

  • It uses the node convention of passing error, result.

    If autocompleter successfully found list of things to show, it should pass null as a first parameter. Passing the error might be useful in cases when something went wrong, and autocompleter wants to show that instead of empty list, but right now this is not implemented.