mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-20 05:10:15 +08:00
account for customizable extra network separators in remove code
previous behavior only searched for leading spaces
This commit is contained in:
parent
6adf2b71c2
commit
41196ccbf7
@ -141,9 +141,12 @@ function setupExtraNetworks() {
|
|||||||
onUiLoaded(setupExtraNetworks);
|
onUiLoaded(setupExtraNetworks);
|
||||||
|
|
||||||
var re_extranet = /<([^:]+:[^:]+):[\d.]+>(.*)/;
|
var re_extranet = /<([^:]+:[^:]+):[\d.]+>(.*)/;
|
||||||
var re_extranet_g = /\s+<([^:]+:[^:]+):[\d.]+>/g;
|
var re_extranet_str = '<([^:]+:[^:]+):[\\d.]+>';
|
||||||
|
|
||||||
function tryToRemoveExtraNetworkFromPrompt(textarea, text) {
|
function tryToRemoveExtraNetworkFromPrompt(textarea, text) {
|
||||||
|
function reEscape(s) {
|
||||||
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||||
|
}
|
||||||
var m = text.match(re_extranet);
|
var m = text.match(re_extranet);
|
||||||
var replaced = false;
|
var replaced = false;
|
||||||
var newTextareaText;
|
var newTextareaText;
|
||||||
@ -151,7 +154,9 @@ function tryToRemoveExtraNetworkFromPrompt(textarea, text) {
|
|||||||
var extraTextAfterNet = m[2];
|
var extraTextAfterNet = m[2];
|
||||||
var partToSearch = m[1];
|
var partToSearch = m[1];
|
||||||
var foundAtPosition = -1;
|
var foundAtPosition = -1;
|
||||||
newTextareaText = textarea.value.replaceAll(re_extranet_g, function(found, net, pos) {
|
var escapedSeparator = reEscape(opts.extra_networks_add_text_separator);
|
||||||
|
var re = new RegExp(escapedSeparator + re_extranet_str, 'g');
|
||||||
|
newTextareaText = textarea.value.replaceAll(re, function(found, net, pos) {
|
||||||
m = found.match(re_extranet);
|
m = found.match(re_extranet);
|
||||||
if (m[1] == partToSearch) {
|
if (m[1] == partToSearch) {
|
||||||
replaced = true;
|
replaced = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user