I want to use autocomplete in the ace editor. After the user types foo.
I want to suggest foo.bar
.
Actually I used the following code:
var langTools = ace.require("ace/ext/language_tools");
var staticWordCompleter = {
identifierRegexps: [/[\.]/],
getCompletions: function(editor, session, pos, prefix, callback) {
console.log(prefix);
if (prefix == "foo.") {
var wordList = ["baar", "bar", "baz"];
callback(null, wordList.map(function(word) {
return {
caption: word,
value: word,
meta: "static"
};
}
}));
}
}
langTools.setCompleters([staticWordCompleter])
If I remove identifierRegexps
and the if
clause, the autocomplete works but not after ".".
I also read this solution but it does not work anymore: Custom autocompleter and periods (.)