diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 2ecf51b..50c11f2 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -234,6 +234,7 @@ async function syncOptions() { useStyleVars: opts["tac_useStyleVars"], // Insertion related settings replaceUnderscores: opts["tac_replaceUnderscores"], + replaceUnderscoresExclusionList: opts["tac_undersocreReplacementExclusionList"], escapeParentheses: opts["tac_escapeParentheses"], appendComma: opts["tac_appendComma"], appendSpace: opts["tac_appendSpace"], @@ -430,8 +431,12 @@ async function insertTextAtCursor(textArea, result, tagword, tabCompletedWithout if (sanitizeResults && sanitizeResults.length > 0) { sanitizedText = sanitizeResults[0]; } else { - sanitizedText = TAC_CFG.replaceUnderscores ? text.replaceAll("_", " ") : text; - + const excluded_tags = TAC_CFG.replaceUnderscoresExclusionList?.split(',').map(s => s.trim()) || []; + if (TAC_CFG.replaceUnderscores && !excluded_tags.includes(sanitizedText)) { + sanitizedText = text.replaceAll("_", " ") + } else { + sanitizedText = text; + } if (TAC_CFG.escapeParentheses && tagType === ResultType.tag) { sanitizedText = sanitizedText .replaceAll("(", "\\(") diff --git a/scripts/tag_autocomplete_helper.py b/scripts/tag_autocomplete_helper.py index 2acca04..cd044f1 100644 --- a/scripts/tag_autocomplete_helper.py +++ b/scripts/tag_autocomplete_helper.py @@ -598,6 +598,7 @@ def on_ui_settings(): "tac_frequencyIncludeAlias": shared.OptionInfo(False, "Frequency sorting matches aliases for frequent tags").info("Tag frequency will be increased for the main tag even if an alias is used for completion. This option can be used to override the default behavior of alias results being ignored for frequency sorting."), # Insertion related settings "tac_replaceUnderscores": shared.OptionInfo(True, "Replace underscores with spaces on insertion"), + "tac_undersocreReplacementExclusionList": shared.OptionInfo("0_0,(o)_(o),+_+,+_-,._.,_,<|>_<|>,=_=,>_<,3_3,6_9,>_o,@_@,^_^,o_o,u_u,x_x,|_|,||_||", "Underscore replacement exclusion list").info("Add tags that shouldn't have underscores replaced with spaces, separated by comma."), "tac_escapeParentheses": shared.OptionInfo(True, "Escape parentheses on insertion"), "tac_appendComma": shared.OptionInfo(True, "Append comma on tag autocompletion"), "tac_appendSpace": shared.OptionInfo(True, "Append space on tag autocompletion").info("will append after comma if the above is enabled"),