Merge pull request #10452 from dongweiming/fix-neg

Fix remove `textual inversion` prompt
This commit is contained in:
AUTOMATIC1111 2023-05-17 08:18:54 +03:00 committed by GitHub
commit 0003b29044
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,11 +68,11 @@ var re_extranet_g = /\s+<([^:]+:[^:]+):[\d\.]+>/g;
function tryToRemoveExtraNetworkFromPrompt(textarea, text){ function tryToRemoveExtraNetworkFromPrompt(textarea, text){
var m = text.match(re_extranet) var m = text.match(re_extranet)
if(! m) return false
var partToSearch = m[1]
var replaced = false var replaced = false
var newTextareaText = textarea.value.replaceAll(re_extranet_g, function(found){ var newTextareaText
if(m) {
var partToSearch = m[1]
newTextareaText = textarea.value.replaceAll(re_extranet_g, function(found){
m = found.match(re_extranet); m = found.match(re_extranet);
if(m[1] == partToSearch){ if(m[1] == partToSearch){
replaced = true; replaced = true;
@ -80,6 +80,15 @@ function tryToRemoveExtraNetworkFromPrompt(textarea, text){
} }
return found; return found;
}) })
} else {
newTextareaText = textarea.value.replaceAll(new RegExp(text, "g"), function(found){
if(found == text) {
replaced = true;
return ""
}
return found;
})
}
if(replaced){ if(replaced){
textarea.value = newTextareaText textarea.value = newTextareaText