Use _ as a stand-in for spaces in < completion

Allows to continue typing embeddings, loras and hypernets if they have spaces in their file name
Closes #130
This commit is contained in:
Dominik Reh
2023-03-01 11:13:37 +01:00
parent 647d3f7ec3
commit d1fff7bfa7
3 changed files with 9 additions and 4 deletions

View File

@@ -12,10 +12,13 @@ class EmbeddingParser extends BaseTagParser {
versionString = searchTerm.slice(0, 2);
searchTerm = searchTerm.slice(2);
}
let filterCondition = x => x[0].toLowerCase().includes(searchTerm) || x[0].toLowerCase().replaceAll(" ", "_").includes(searchTerm);
if (versionString)
tempResults = embeddings.filter(x => x[0].toLowerCase().includes(searchTerm) && x[1] && x[1] === versionString); // Filter by tagword
tempResults = embeddings.filter(x => filterCondition(x) && x[1] && x[1] === versionString); // Filter by tagword
else
tempResults = embeddings.filter(x => x[0].toLowerCase().includes(searchTerm)); // Filter by tagword
tempResults = embeddings.filter(x => filterCondition(x)); // Filter by tagword
} else {
tempResults = embeddings;
}

View File

@@ -7,7 +7,8 @@ class HypernetParser extends BaseTagParser {
let tempResults = [];
if (tagword !== "<" && tagword !== "<h:" && tagword !== "<hypernet:") {
let searchTerm = tagword.replace("<hypernet:", "").replace("<h:", "").replace("<", "");
tempResults = hypernetworks.filter(x => x.toLowerCase().includes(searchTerm)); // Filter by tagword
let filterCondition = x => x.toLowerCase().includes(searchTerm) || x.toLowerCase().replaceAll(" ", "_").includes(searchTerm);
tempResults = hypernetworks.filter(x => filterCondition(x)); // Filter by tagword
} else {
tempResults = hypernetworks;
}

View File

@@ -7,7 +7,8 @@ class LoraParser extends BaseTagParser {
let tempResults = [];
if (tagword !== "<" && tagword !== "<l:" && tagword !== "<lora:") {
let searchTerm = tagword.replace("<lora:", "").replace("<l:", "").replace("<", "");
tempResults = loras.filter(x => x.toLowerCase().includes(searchTerm)); // Filter by tagword
let filterCondition = x => x.toLowerCase().includes(searchTerm) || x.toLowerCase().replaceAll(" ", "_").includes(searchTerm);
tempResults = loras.filter(x => filterCondition(x)); // Filter by tagword
} else {
tempResults = loras;
}