mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
fix alias list in help string
This commit is contained in:
@ -1909,13 +1909,26 @@ export function setSlashCommandAutoComplete(textarea, isFloating = false) {
|
|||||||
;
|
;
|
||||||
result = helpStrings
|
result = helpStrings
|
||||||
.filter((it,idx)=>[idx, -1].includes(helpStrings.indexOf(parser.commands[it].name.toLowerCase()))) // remove duplicates
|
.filter((it,idx)=>[idx, -1].includes(helpStrings.indexOf(parser.commands[it].name.toLowerCase()))) // remove duplicates
|
||||||
.map(it => ({
|
.map(name => {
|
||||||
name: it,
|
const cmd = parser.commands[name];
|
||||||
label: `${buildHelpStringName(it)}${parser.commands[it].helpStringFormattedWithoutName}`,
|
let aliases = '';
|
||||||
value: `/${it}`,
|
if (cmd.aliases?.length > 0) {
|
||||||
score: matchType == 'fuzzy' ? fuzzyScore(it) : null,
|
aliases = ' (alias: ';
|
||||||
li: null,
|
aliases += [cmd.name, ...cmd.aliases]
|
||||||
})) // Map to the help string and score
|
.filter(it=>it != name)
|
||||||
|
.map(it=>`<span class="monospace">/${it}</span>`)
|
||||||
|
.join(', ')
|
||||||
|
;
|
||||||
|
aliases += ')';
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
name: name,
|
||||||
|
label: `${buildHelpStringName(name)}${cmd.helpString}${aliases}`,
|
||||||
|
value: `/${name}`,
|
||||||
|
score: matchType == 'fuzzy' ? fuzzyScore(name) : null,
|
||||||
|
li: null,
|
||||||
|
};
|
||||||
|
}) // Map to the help string and score
|
||||||
.toSorted(matchType == 'fuzzy' ? fuzzyScoreCompare : (a, b) => a.name.localeCompare(b.name)) // sort by score (if fuzzy) or name
|
.toSorted(matchType == 'fuzzy' ? fuzzyScoreCompare : (a, b) => a.name.localeCompare(b.name)) // sort by score (if fuzzy) or name
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@ export class SlashCommand {
|
|||||||
/**@type {String}*/ name;
|
/**@type {String}*/ name;
|
||||||
/**@type {Function}*/ callback;
|
/**@type {Function}*/ callback;
|
||||||
/**@type {String}*/ helpString;
|
/**@type {String}*/ helpString;
|
||||||
/**@type {String}*/ helpStringFormatted;
|
|
||||||
/**@type {String}*/ helpStringFormattedWithoutName;
|
|
||||||
/**@type {Boolean}*/ interruptsGeneration;
|
/**@type {Boolean}*/ interruptsGeneration;
|
||||||
/**@type {Boolean}*/ purgeFromMessage;
|
/**@type {Boolean}*/ purgeFromMessage;
|
||||||
/**@type {String[]}*/ aliases;
|
/**@type {String[]}*/ aliases;
|
||||||
|
@ -150,16 +150,6 @@ export class SlashCommandParser {
|
|||||||
this.commands[alias] = fnObj;
|
this.commands[alias] = fnObj;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let stringBuilder = `${helpString} `;
|
|
||||||
if (Array.isArray(aliases) && aliases.length) {
|
|
||||||
let aliasesString = `(alias: ${aliases.map(x => `<span class="monospace">/${x}</span>`).join(', ')})`;
|
|
||||||
stringBuilder += aliasesString;
|
|
||||||
}
|
|
||||||
fnObj.helpStringFormattedWithoutName = stringBuilder;
|
|
||||||
stringBuilder = `<span class="monospace">/${command}</span> ${stringBuilder}`;
|
|
||||||
this.helpStrings[command] = stringBuilder;
|
|
||||||
fnObj.helpStringFormatted = stringBuilder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getHelpString() {
|
getHelpString() {
|
||||||
|
Reference in New Issue
Block a user