Include synonyms in autocomplete
This commit is contained in:
parent
06ebcbff8c
commit
439a7dc5e6
1 changed files with 20 additions and 9 deletions
|
|
@ -74,15 +74,26 @@ const isValidDoc = (doc) => {
|
||||||
const hasExcludedTags = (doc) =>
|
const hasExcludedTags = (doc) =>
|
||||||
['superdirtOnly', 'noAutocomplete'].some((tag) => doc.tags?.find((t) => t.originalTitle === tag));
|
['superdirtOnly', 'noAutocomplete'].some((tag) => doc.tags?.find((t) => t.originalTitle === tag));
|
||||||
|
|
||||||
const jsdocCompletions = jsdoc.docs
|
const jsdocCompletions = (() => {
|
||||||
.filter((doc) => isValidDoc(doc) && !hasExcludedTags(doc))
|
const seen = new Set(); // avoid repetition
|
||||||
// https://codemirror.net/docs/ref/#autocomplete.Completion
|
const completions = [];
|
||||||
.map((doc) => ({
|
for (const doc of jsdoc.docs) {
|
||||||
label: getDocLabel(doc),
|
if (!isValidDoc(doc) || hasExcludedTags(doc)) continue;
|
||||||
// detail: 'xxx', // An optional short piece of information to show (with a different style) after the label.
|
let labels = [getDocLabel(doc), ...(doc.synonyms || [])];
|
||||||
info: () => Autocomplete({ doc }),
|
for (const label of labels) {
|
||||||
type: 'function', // https://codemirror.net/docs/ref/#autocomplete.Completion.type
|
// https://codemirror.net/docs/ref/#autocomplete.Completion
|
||||||
}));
|
if (label && !seen.has(label)) {
|
||||||
|
seen.add(label);
|
||||||
|
completions.push({
|
||||||
|
label,
|
||||||
|
info: () => Autocomplete({ doc }),
|
||||||
|
type: 'function', // https://codemirror.net/docs/ref/#autocomplete.Completion.type
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return completions;
|
||||||
|
})();
|
||||||
|
|
||||||
export const strudelAutocomplete = (context) => {
|
export const strudelAutocomplete = (context) => {
|
||||||
const word = context.matchBefore(/\w*/);
|
const word = context.matchBefore(/\w*/);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue