Add separate "append spaces" setting

Also rewrote settings to use newer webui features
This commit is contained in:
DominikDoom
2023-07-06 12:39:47 +02:00
parent 7f18856321
commit 922414b4ba
2 changed files with 59 additions and 43 deletions

View File

@@ -199,6 +199,7 @@ async function syncOptions() {
replaceUnderscores: opts["tac_replaceUnderscores"],
escapeParentheses: opts["tac_escapeParentheses"],
appendComma: opts["tac_appendComma"],
appendSpace: opts["tac_appendSpace"],
wildcardCompletionMode: opts["tac_wildcardCompletionMode"],
// Alias settings
alias: {
@@ -418,8 +419,12 @@ async function insertTextAtCursor(textArea, result, tagword, tabCompletedWithout
var optionalSeparator = "";
let extraNetworkTypes = [ResultType.hypernetwork, ResultType.lora];
let noCommaTypes = [ResultType.wildcardFile, ResultType.yamlWildcard].concat(extraNetworkTypes);
if (TAC_CFG.appendComma && !noCommaTypes.includes(tagType)) {
optionalSeparator = surrounding.match(new RegExp(`${escapeRegExp(tagword)}[,:]`, "i")) !== null ? "" : ", ";
if (!noCommaTypes.includes(tagType)) {
if (TAC_CFG.appendComma)
optionalSeparator = surrounding.match(new RegExp(`${escapeRegExp(tagword)}[,:]`, "i")) !== null ? "" : ",";
if (TAC_CFG.appendSpace)
optionalSeparator += " ";
} else if (extraNetworkTypes.includes(tagType)) {
// Use the dedicated separator for extra networks if it's defined, otherwise fall back to space
optionalSeparator = TAC_CFG.extraNetworksSeparator || " ";