Reputation: 115
I am trying to implement custom and basic auto-completion in the ace editor at the same time, I am following the stack overflow article ACE Editor Autocomplete - custom strings. But when I try to press some character, then I am getting the below Error
ERROR TypeError: Cannot read property 'map' of undefined. The code that I am using is
var staticWordCompleter={
getCompletions: function(editor, session, pos, prefix, callback) {
if (prefix.length === 0) {
callback(null, []);
return
}
var wordList = ["foo", "bar", "baz"];
callback(null, [...wordList.map(function(word) {
return {
caption: word,
value: word,
meta: "static"
};
}),
...session.$mode.$highlightRules.$keywordList.map(function(word) {
return {
caption: word,
value: word,
meta: 'keyword',
};
})
]);
}
when I remove the above code then basic auto-completion working pretty fine as usual. And when I remove the following code from the above code:
...session.$mode.$highlightRules.$keywordList.map(function(word) {
return {
caption: word,
value: word,
meta: 'keyword',
};
})
then it only gives auto-suggestion of custom auto-completion code. Please help me how to implement both at a time.
Upvotes: 2
Views: 1024
Reputation: 53
var staticWordCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
var wordList = ["foo", "bar", "baz"];
callback(null, wordList.map(function(word) {
return {
caption: word,
value: word,
meta: "static"
};
}));
}
}
langTools.addCompleter(staticWordCompleter);
Upvotes: 2