What is the correct way of debouncing an async completion. I tried debouncing the source function but the tooltip won’t load until the very next input after the debounce threshold.
import { debounce } from "lodash";
const state = EditorState.create({
doc: "",
extensions: [
basicSetup,
oneDark,
getLanguage(language),
autocompletion({
override: [
debounce(
async function sources(context: CompletionContext) {
const word = context.matchBefore(/.*/);
if (word.from == word.to && !context.explicit) return null;
const options = await fetchStuff(word.text);
return { from: word.from, options };
},
300
)
],
}),
],
});