Fix keyword name check for single element dicts

(important for user defined mappings with a unique hash)
This commit is contained in:
DominikDoom
2023-07-22 13:41:48 +02:00
parent 40d9fc1079
commit f1d911834b
2 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -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");
}