From d1fff7bfa70bb58200464aa185b7ca8383538a17 Mon Sep 17 00:00:00 2001 From: Dominik Reh Date: Wed, 1 Mar 2023 11:13:37 +0100 Subject: [PATCH] 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 --- javascript/ext_embeddings.js | 7 +++++-- javascript/ext_hypernets.js | 3 ++- javascript/ext_loras.js | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/javascript/ext_embeddings.js b/javascript/ext_embeddings.js index 409118c..2bfbaf6 100644 --- a/javascript/ext_embeddings.js +++ b/javascript/ext_embeddings.js @@ -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; } diff --git a/javascript/ext_hypernets.js b/javascript/ext_hypernets.js index aedf9ad..371b85d 100644 --- a/javascript/ext_hypernets.js +++ b/javascript/ext_hypernets.js @@ -7,7 +7,8 @@ class HypernetParser extends BaseTagParser { let tempResults = []; if (tagword !== "<" && tagword !== " 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; } diff --git a/javascript/ext_loras.js b/javascript/ext_loras.js index 4fb1ce1..2f11fb1 100644 --- a/javascript/ext_loras.js +++ b/javascript/ext_loras.js @@ -7,7 +7,8 @@ class LoraParser extends BaseTagParser { let tempResults = []; if (tagword !== "<" && tagword !== " 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; }