mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
feat(autocomplete): add setting to toggle comma separator between tags
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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 ---
|
||||
|
||||
Reference in New Issue
Block a user