mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Don't allow duplicate registrations
This commit is contained in:
@ -50,8 +50,8 @@ export class MacrosParser {
|
|||||||
* @returns {IterableIterator<CustomMacro>}
|
* @returns {IterableIterator<CustomMacro>}
|
||||||
*/
|
*/
|
||||||
static [Symbol.iterator] = function* () {
|
static [Symbol.iterator] = function* () {
|
||||||
for (const macro of this.#macros.values()) {
|
for (const macro of MacrosParser.#macros.keys()) {
|
||||||
yield { key: macro, description: this.#descriptions.get(macro) };
|
yield { key: macro, description: MacrosParser.#descriptions.get(macro) };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import { SlashCommandDebugController } from './SlashCommandDebugController.js';
|
|||||||
import { commonEnumProviders } from './SlashCommandCommonEnumsProvider.js';
|
import { commonEnumProviders } from './SlashCommandCommonEnumsProvider.js';
|
||||||
import { SlashCommandBreak } from './SlashCommandBreak.js';
|
import { SlashCommandBreak } from './SlashCommandBreak.js';
|
||||||
import { MacrosParser } from '../macros.js';
|
import { MacrosParser } from '../macros.js';
|
||||||
|
import { t } from '../i18n.js';
|
||||||
|
|
||||||
/** @typedef {import('./SlashCommand.js').NamedArgumentsCapture} NamedArgumentsCapture */
|
/** @typedef {import('./SlashCommand.js').NamedArgumentsCapture} NamedArgumentsCapture */
|
||||||
/** @typedef {import('./SlashCommand.js').NamedArguments} NamedArguments */
|
/** @typedef {import('./SlashCommand.js').NamedArguments} NamedArguments */
|
||||||
@ -496,7 +497,8 @@ export class SlashCommandParser {
|
|||||||
(li.querySelector('tt').remove(),li.innerHTML),
|
(li.querySelector('tt').remove(),li.innerHTML),
|
||||||
));
|
));
|
||||||
for (const macro of MacrosParser) {
|
for (const macro of MacrosParser) {
|
||||||
options.push(new MacroAutoCompleteOption(macro.name, `{{${macro.name}}}`, macro.description || 'No description provided'));
|
if (options.find(it => it.name === macro.key)) continue;
|
||||||
|
options.push(new MacroAutoCompleteOption(macro.key, `{{${macro.key}}}`, macro.description || t`No description provided`));
|
||||||
}
|
}
|
||||||
const result = new AutoCompleteNameResult(
|
const result = new AutoCompleteNameResult(
|
||||||
macro.name,
|
macro.name,
|
||||||
|
Reference in New Issue
Block a user