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();