Insert missing ooba samplers

b1bb41313f74e6df90624024031e62d703dc974f

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +16 -0Showing whitespace changes
public/scripts/textgen-settings.js+16 -0
@@ -805,6 +805,21 @@ function showTypeSpecificControls(type) {
805805 });
806806}
807807
808+/**
809+ * Inserts missing items from the source array into the target array.
810+ * @param {any[]} source - Source array
811+ * @param {any[]} target - Target array
812+ * @returns {void}
813+ */
814+function insertMissingArrayItems(source, target) {
815+ for (const item of source) {
816+ if (!target.includes(item)) {
817+ const index = source.indexOf(item);
818+ target.splice(index, 0, item);
819+ }
820+ }
821+}
822+
808823function setSettingByName(setting, value, trigger) {
809824 if (value === null || value === undefined) {
810825 return;
@@ -819,6 +834,7 @@ function setSettingByName(setting, value, trigger) {
819834
820835 if ('sampler_priority' === setting) {
821836 value = Array.isArray(value) ? value : OOBA_DEFAULT_ORDER;
837+ insertMissingArrayItems(OOBA_DEFAULT_ORDER, value);
822838 sortOobaItemsByOrder(value);
823839 settings.sampler_priority = value;
824840 return;