From f1d911834ba2ac2539aae945eba4503b975eeca1 Mon Sep 17 00:00:00 2001 From: DominikDoom Date: Sat, 22 Jul 2023 13:41:48 +0200 Subject: [PATCH] Fix keyword name check for single element dicts (important for user defined mappings with a unique hash) --- javascript/ext_modelKeyword.js | 3 ++- javascript/tagAutocomplete.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/javascript/ext_modelKeyword.js b/javascript/ext_modelKeyword.js index d170f50..8f80c4f 100644 --- a/javascript/ext_modelKeyword.js +++ b/javascript/ext_modelKeyword.js @@ -17,7 +17,8 @@ async function load() { const parts = line.split(","); const hash = parts[0]; const keywords = parts[1].replaceAll("| ", ", ").replaceAll("|", ", ").trim(); - const name = parts[2]?.trim() || "none" + const lastSepIndex = parts[2]?.lastIndexOf("/") + 1 || parts[2]?.lastIndexOf("\\") + 1 || 0; + const name = parts[2]?.substring(lastSepIndex).trim() || "none" if (modelKeywordDict.has(hash) && name !== "none") { // Add a new name key if the hash already exists diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 879beb1..d7ee40a 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -452,9 +452,9 @@ async function insertTextAtCursor(textArea, result, tagword, tabCompletedWithout let name = result.text + ".safetensors"; if (nameDict) { - if (nameDict.size > 1) + if (nameDict.has(name)) keywords = nameDict.get(name); - else + else keywords = nameDict.get("none"); }