feat(autocomplete): add setting to toggle comma separator between tags

This commit is contained in:
CalamitousFelicitousness
2026-03-26 01:56:57 +00:00
parent 30d3415e9e
commit 97d3854e4b
2 changed files with 6 additions and 3 deletions
+5 -3
View File
@@ -215,9 +215,11 @@ function insertTag(textarea, tagName) {
const before = value.slice(0, info.start);
const after = value.slice(info.end);
// Build insertion: tag + separator
const needsCommaBefore = before.length > 0 && !before.trimEnd().endsWith(',') && before.trimEnd().length > 0;
const prefix = needsCommaBefore ? ', ' : '';
let suffix = ', ';
const useComma = window.opts?.autocomplete_append_comma ?? true;
const sep = useComma ? ',' : '';
const needsSepBefore = before.length > 0 && before.trimEnd().length > 0 && !before.trimEnd().endsWith(',');
const prefix = needsSepBefore ? `${sep} ` : '';
let suffix = `${sep} `;
if (after.length > 0 && after.trimStart().startsWith(',')) suffix = ' ';
const insertion = `${prefix}${tagName}${suffix}`;
textarea.value = before.trimEnd() + (before.trimEnd().length > 0 ? ' ' : '') + insertion + after.trimStart();
+1
View File
@@ -665,6 +665,7 @@ def create_settings(cmd_opts):
"autocomplete_enabled": OptionInfo([], "Enabled tag autocomplete files", gr.Dropdown, lambda: {"multiselect": True, "choices": list_autocomplete_names()}),
"autocomplete_min_chars": OptionInfo(3, "Minimum characters before autocomplete triggers", gr.Slider, {"minimum": 2, "maximum": 6, "step": 1}),
"autocomplete_replace_underscores": OptionInfo(True, "Replace underscores with spaces in autocomplete results"),
"autocomplete_append_comma": OptionInfo(True, "Automatically add comma separator between tags"),
}))
# --- Extensions ---