Update autocomplete name to be the label and update ref to use main name as a synonym
This commit is contained in:
parent
8d2a368da9
commit
c199b51645
3 changed files with 11 additions and 6 deletions
|
|
@ -86,7 +86,7 @@ const jsdocCompletions = (() => {
|
||||||
seen.add(label);
|
seen.add(label);
|
||||||
completions.push({
|
completions.push({
|
||||||
label,
|
label,
|
||||||
info: () => Autocomplete({ doc }),
|
info: () => Autocomplete({ doc, label }),
|
||||||
type: 'function', // https://codemirror.net/docs/ref/#autocomplete.Completion.type
|
type: 'function', // https://codemirror.net/docs/ref/#autocomplete.Completion.type
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,27 @@ import { useMemo, useState } from 'react';
|
||||||
import jsdocJson from '../../../../../doc.json';
|
import jsdocJson from '../../../../../doc.json';
|
||||||
import { Textbox } from '../textbox/Textbox';
|
import { Textbox } from '../textbox/Textbox';
|
||||||
|
|
||||||
const isValid = ({ name, description }) =>
|
const isValid = ({ name, description }) => name && !name.startsWith('_') && !!description;
|
||||||
name && !name.startsWith('_') && !!description;
|
|
||||||
|
|
||||||
const availableFunctions = (() => {
|
const availableFunctions = (() => {
|
||||||
const seen = new Set(); // avoid repetition
|
const seen = new Set(); // avoid repetition
|
||||||
const functions = [];
|
const functions = [];
|
||||||
for (const doc of jsdocJson.docs) {
|
for (const doc of jsdocJson.docs) {
|
||||||
if (!isValid(doc)) continue;
|
if (!isValid(doc)) continue;
|
||||||
let docAndSynonyms = [doc.name, ...(doc.synonyms || [])];
|
functions.push(doc);
|
||||||
for (const s of docAndSynonyms) {
|
const synonyms = doc.synonyms || [];
|
||||||
|
for (const s of synonyms) {
|
||||||
if (!s || seen.has(s)) continue;
|
if (!s || seen.has(s)) continue;
|
||||||
seen.add(s);
|
seen.add(s);
|
||||||
|
// Swap `doc.name` in for `s` in the list of synonyms
|
||||||
|
const notS = synonyms.filter((x) => x && x !== s);
|
||||||
|
const synonymsWithDoc = Array.from(new Set([doc.name, ...notS]));
|
||||||
functions.push({
|
functions.push({
|
||||||
...doc,
|
...doc,
|
||||||
name: s, // update names for the synonym
|
name: s, // update names for the synonym
|
||||||
longname: s,
|
longname: s,
|
||||||
|
synonyms: synonymsWithDoc,
|
||||||
|
synonyms_text: synonymsWithDoc.join(', '),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ export function SettingsTab({ started }) {
|
||||||
confirmDialog('Sure?').then((r) => {
|
confirmDialog('Sure?').then((r) => {
|
||||||
if (r) {
|
if (r) {
|
||||||
const { userPatterns } = settingsMap.get(); // keep current patterns
|
const { userPatterns } = settingsMap.get(); // keep current patterns
|
||||||
settingsMap.set({...defaultSettings, userPatterns});
|
settingsMap.set({ ...defaultSettings, userPatterns });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue