diff options
author | missionfloyd <missionfloyd@users.noreply.github.com> | 2023-04-20 07:12:59 +0000 |
---|---|---|
committer | missionfloyd <missionfloyd@users.noreply.github.com> | 2023-04-20 07:12:59 +0000 |
commit | fbd34a68478caa528507fab830e3ac33a26fc6f4 (patch) | |
tree | 9b91111b9be62b05b82528a108fd45e8e2ed8d6c /javascript/edit-attention.js | |
parent | e735be8b5b455aa2bd02be0b3c6fe0596ad4ec52 (diff) | |
download | stable-diffusion-webui-gfx803-fbd34a68478caa528507fab830e3ac33a26fc6f4.tar.gz stable-diffusion-webui-gfx803-fbd34a68478caa528507fab830e3ac33a26fc6f4.tar.bz2 stable-diffusion-webui-gfx803-fbd34a68478caa528507fab830e3ac33a26fc6f4.zip |
Use string.contains() instead of regex
Diffstat (limited to 'javascript/edit-attention.js')
-rw-r--r-- | javascript/edit-attention.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/javascript/edit-attention.js b/javascript/edit-attention.js index 1c9f6737..01d37074 100644 --- a/javascript/edit-attention.js +++ b/javascript/edit-attention.js @@ -46,6 +46,7 @@ function keyupEditAttention(event){ function selectCurrentWord(){
if (selectionStart !== selectionEnd) return false;
+ const delimiters = ".,\/#!$%\^&\*;:{}=\-_`~()";
// Select the current word, find the start and end of the word (first space before and after)
const wordStart = text.substring(0, selectionStart).lastIndexOf(" ") + 1;
@@ -59,10 +60,10 @@ function keyupEditAttention(event){ selectionStart = wordStart;
// Remove all punctuation at the end and beginning of the word
- while (text[selectionStart].match(/[.,\/#!$%\^&\*;:{}=\-_`~()]/)) {
+ while (delimiters.includes(text[selectionStart])) {
selectionStart++;
}
- while (text[selectionEnd - 1].match(/[.,\/#!$%\^&\*;:{}=\-_`~()]/)) {
+ while (delimiters.includes(text[selectionEnd - 1])) {
selectionEnd--;
}
target.setSelectionRange(selectionStart, selectionEnd);
|