From 737b697357af06eb2edb392a5b82d98f6e726637 Mon Sep 17 00:00:00 2001 From: DominikDoom Date: Sat, 8 Jul 2023 18:03:44 +0200 Subject: [PATCH] Fix for insertion adding space before comma even if not needed --- javascript/tagAutocomplete.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 1094a0e..6d3360a 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -422,10 +422,11 @@ async function insertTextAtCursor(textArea, result, tagword, tabCompletedWithout let noCommaTypes = [ResultType.wildcardFile, ResultType.yamlWildcard].concat(extraNetworkTypes); if (!noCommaTypes.includes(tagType)) { // Append comma if enabled and not already present + let beforeComma = surrounding.match(new RegExp(`${escapeRegExp(tagword)}[,:]`, "i")) !== null; if (TAC_CFG.appendComma) - optionalSeparator = surrounding.match(new RegExp(`${escapeRegExp(tagword)}[,:]`, "i")) !== null ? "" : ","; + optionalSeparator = beforeComma ? "" : ","; // Add space if enabled - if (TAC_CFG.appendSpace) + if (TAC_CFG.appendSpace && !beforeComma) optionalSeparator += " "; // If at end of prompt and enabled, override the normal setting if not already added if (!TAC_CFG.appendSpace && TAC_CFG.alwaysSpaceAtEnd)