In Ace Editor I'm trying to add some custom code stubs for internal libraries. However, the Ace autocomplete fires on any entry into the editor, even if it doesn't match the word
property.
Is there a way in Ace to bring up the result only when the user types the word
into the IDE? For example, if they type 'text' it would bring up my custom code, if they typed 'new' it would only bring up local variables and the keyword new.
autoCompleteList.getWordList = () => {
return [
{ word: text, result: new myClass{some props}, meta: "Query"}]
}
And then using this code for the editor
getCompletions: (editor, session, pos, prefix, callback) => {
if (prefix.length === 0) {
callback(null, []);
return;
}
callback(null, wordList.map( element => {
return {
name: element.word,
value: element.result,
meta: "keyword"
};
}));
}
I have tried changing the meta on all to 'Query' and was expecting that to only fire the Ace Autocomplete on the user typing in the value stores in the word
property.
The easiest way is to inspect what's in the session
before pos
using a TokenIterator (ace.require("ace/token_iterator").TokenIterator
) - if it's not preceded by a token you'd like, feed [] to callback as you already do.