not sure if this is relevant anymore but i followed this suggestion and wrapped my completion source to customize the list. myCompletions
takes in a list and further customizes it). but now that im including it with the following
EditorState.languageData.of(() => [{ autocomplete: myCompletions(customList) }])
the autocomplete dropdown doesn’t close after making a selection or when i delete characters (and eventually i dont have any characters before the cursor). what could i be doing wrong?
export function myCompletions(list: string[], isCustomize: boolean) {
return (ctx: CompletionContext) => {
const before = ctx.matchBefore(/[\w$]+/);
if (!ctx.explicit && !before) {
return null;
}
const currentWord = before.text;
const regex = new RegExp(`^${currentWord}`, 'i'); // regex for matches in custom list
const resultList = !currentWord
? list
: list.filter((item: string) => item.match(regex)).sort();
const finalResult = isCustomize
? customize(resultList)
: resultList;
return completeFromList(finalResult as string[]);
};
}