diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 86fc25ff4..37f8b7d3c 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -805,6 +805,21 @@ function showTypeSpecificControls(type) { }); } +/** + * Inserts missing items from the source array into the target array. + * @param {any[]} source - Source array + * @param {any[]} target - Target array + * @returns {void} + */ +function insertMissingArrayItems(source, target) { + for (const item of source) { + if (!target.includes(item)) { + const index = source.indexOf(item); + target.splice(index, 0, item); + } + } +} + function setSettingByName(setting, value, trigger) { if (value === null || value === undefined) { return; @@ -819,6 +834,7 @@ function setSettingByName(setting, value, trigger) { if ('sampler_priority' === setting) { value = Array.isArray(value) ? value : OOBA_DEFAULT_ORDER; + insertMissingArrayItems(OOBA_DEFAULT_ORDER, value); sortOobaItemsByOrder(value); settings.sampler_priority = value; return;