mirror of
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git
synced 2026-01-26 19:19:57 +00:00
Fix extra network sorting
Caused by loras including their (hidden) folder prefixes instead of just by name
This commit is contained in:
@@ -16,7 +16,12 @@ class LoraParser extends BaseTagParser {
|
||||
// Add final results
|
||||
let finalResults = [];
|
||||
tempResults.forEach(t => {
|
||||
let result = new AutocompleteResult(t[0].trim(), ResultType.lora)
|
||||
const text = t[0].trim();
|
||||
let lastDot = text.lastIndexOf(".") > -1 ? text.lastIndexOf(".") : text.length;
|
||||
let lastSlash = text.lastIndexOf("/") > -1 ? text.lastIndexOf("/") : 0;
|
||||
let name = text.substring(lastSlash + 1, lastDot);
|
||||
|
||||
let result = new AutocompleteResult(name, ResultType.lora)
|
||||
result.meta = "Lora";
|
||||
result.hash = t[1];
|
||||
finalResults.push(result);
|
||||
@@ -41,17 +46,12 @@ async function load() {
|
||||
async function sanitize(tagType, text) {
|
||||
if (tagType === ResultType.lora) {
|
||||
let multiplier = TAC_CFG.extraNetworksDefaultMultiplier;
|
||||
let finalComponent = text.lastIndexOf("/") > -1 ? text.substring(text.lastIndexOf("/") + 1) : text;
|
||||
let info = await fetchAPI(`tacapi/v1/lora-info/${finalComponent}`)
|
||||
let info = await fetchAPI(`tacapi/v1/lora-info/${text}`)
|
||||
if (info && info["preferred weight"]) {
|
||||
multiplier = info["preferred weight"];
|
||||
}
|
||||
|
||||
const lastDot = text.lastIndexOf(".");
|
||||
const lastSlash = text.lastIndexOf("/");
|
||||
const name = text.substring(lastSlash + 1, lastDot);
|
||||
|
||||
return `<lora:${name}:${multiplier}>`;
|
||||
return `<lora:${text}:${multiplier}>`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,12 @@ class LycoParser extends BaseTagParser {
|
||||
// Add final results
|
||||
let finalResults = [];
|
||||
tempResults.forEach(t => {
|
||||
let result = new AutocompleteResult(t[0].trim(), ResultType.lyco)
|
||||
const text = t[0].trim();
|
||||
let lastDot = text.lastIndexOf(".") > -1 ? text.lastIndexOf(".") : text.length;
|
||||
let lastSlash = text.lastIndexOf("/") > -1 ? text.lastIndexOf("/") : 0;
|
||||
let name = text.substring(lastSlash + 1, lastDot);
|
||||
|
||||
let result = new AutocompleteResult(name, ResultType.lyco)
|
||||
result.meta = "Lyco";
|
||||
result.hash = t[1];
|
||||
finalResults.push(result);
|
||||
@@ -41,17 +46,12 @@ async function load() {
|
||||
async function sanitize(tagType, text) {
|
||||
if (tagType === ResultType.lyco) {
|
||||
let multiplier = TAC_CFG.extraNetworksDefaultMultiplier;
|
||||
let finalComponent = text.lastIndexOf("/") > -1 ? text.substring(text.lastIndexOf("/") + 1) : text;
|
||||
let info = await fetchAPI(`tacapi/v1/lyco-info/${finalComponent}`)
|
||||
let info = await fetchAPI(`tacapi/v1/lyco-info/${text}`)
|
||||
if (info && info["preferred weight"]) {
|
||||
multiplier = info["preferred weight"];
|
||||
}
|
||||
|
||||
const lastDot = text.lastIndexOf(".");
|
||||
const lastSlash = text.lastIndexOf("/");
|
||||
const name = text.substring(lastSlash + 1, lastDot);
|
||||
|
||||
return `<lyco:${name}:${multiplier}>`;
|
||||
return `<lyco:${text}:${multiplier}>`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -453,8 +453,7 @@ async function insertTextAtCursor(textArea, result, tagword, tabCompletedWithout
|
||||
let keywords = null;
|
||||
// Check built-in activation words first
|
||||
if (tagType === ResultType.lora || tagType === ResultType.lyco) {
|
||||
let finalComponent = result.text.lastIndexOf("/") > -1 ? result.text.substring(result.text.lastIndexOf("/") + 1) : result.text;
|
||||
let info = await fetchAPI(`tacapi/v1/lora-info/${finalComponent}`)
|
||||
let info = await fetchAPI(`tacapi/v1/lora-info/${result.text}`)
|
||||
if (info && info["activation text"]) {
|
||||
keywords = info["activation text"];
|
||||
}
|
||||
@@ -585,11 +584,6 @@ function addResultsToList(textArea, results, tagword, resetList) {
|
||||
|
||||
if (!TAC_CFG.alias.onlyShowAlias && result.text !== bestAlias)
|
||||
displayText += " ➝ " + result.text;
|
||||
} else if (result.type === ResultType.lora || result.type === ResultType.lyco) {
|
||||
let lastDot = result.text.lastIndexOf(".");
|
||||
let lastSlash = result.text.lastIndexOf("/");
|
||||
let name = result.text.substring(lastSlash + 1, lastDot);
|
||||
displayText = escapeHTML(name);
|
||||
} else { // No alias
|
||||
displayText = escapeHTML(result.text);
|
||||
}
|
||||
@@ -713,7 +707,11 @@ function updateSelectionStyle(textArea, newIndex, oldIndex) {
|
||||
|
||||
// make it safer
|
||||
if (newIndex !== null) {
|
||||
items[newIndex].classList.add('selected');
|
||||
let selected = items[newIndex];
|
||||
selected.classList.add('selected');
|
||||
|
||||
// Set scrolltop to selected item
|
||||
resultDiv.scrollTop = selected.offsetTop - resultDiv.offsetTop;
|
||||
}
|
||||
|
||||
// Set scrolltop to selected item if we are showing more than max results
|
||||
|
||||
Reference in New Issue
Block a user