@@ -140,14 +140,15 @@ function setupExtraNetworks() {
140
140
141
141
onUiLoaded ( setupExtraNetworks ) ;
142
142
143
- var re_extranet = / < ( [ ^ : ] + : [ ^ : ] + ) : [ \d . ] + > ( .* ) / ;
144
- var re_extranet_g = / \s + < ( [ ^ : ] + : [ ^ : ] + ) : [ \d . ] + > / g;
143
+ var re_extranet = / < ( [ ^ : ^ > ] + : [ ^ : ] + ) : [ \d . ] + > ( .* ) / ;
144
+ var re_extranet_g = / < ( [ ^ : ^ > ] + : [ ^ : ] + ) : [ \d . ] + > / g;
145
145
146
146
function tryToRemoveExtraNetworkFromPrompt ( textarea , text ) {
147
147
var m = text . match ( re_extranet ) ;
148
148
var replaced = false ;
149
149
var newTextareaText ;
150
150
if ( m ) {
151
+ var extraTextBeforeNet = opts . extra_networks_add_text_separator ;
151
152
var extraTextAfterNet = m [ 2 ] ;
152
153
var partToSearch = m [ 1 ] ;
153
154
var foundAtPosition = - 1 ;
@@ -161,8 +162,13 @@ function tryToRemoveExtraNetworkFromPrompt(textarea, text) {
161
162
return found ;
162
163
} ) ;
163
164
164
- if ( foundAtPosition >= 0 && newTextareaText . substr ( foundAtPosition , extraTextAfterNet . length ) == extraTextAfterNet ) {
165
- newTextareaText = newTextareaText . substr ( 0 , foundAtPosition ) + newTextareaText . substr ( foundAtPosition + extraTextAfterNet . length ) ;
165
+ if ( foundAtPosition >= 0 ) {
166
+ if ( newTextareaText . substr ( foundAtPosition , extraTextAfterNet . length ) == extraTextAfterNet ) {
167
+ newTextareaText = newTextareaText . substr ( 0 , foundAtPosition ) + newTextareaText . substr ( foundAtPosition + extraTextAfterNet . length ) ;
168
+ }
169
+ if ( newTextareaText . substr ( foundAtPosition - extraTextBeforeNet . length , extraTextBeforeNet . length ) == extraTextBeforeNet ) {
170
+ newTextareaText = newTextareaText . substr ( 0 , foundAtPosition - extraTextBeforeNet . length ) + newTextareaText . substr ( foundAtPosition ) ;
171
+ }
166
172
}
167
173
} else {
168
174
newTextareaText = textarea . value . replaceAll ( new RegExp ( text , "g" ) , function ( found ) {
0 commit comments