mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-20 11:23:29 +00:00
correctly checks end of the text
This commit is contained in:
parent
79ba0399d8
commit
a962222992
@ -79,8 +79,16 @@ name:id,
|
|||||||
selectedText = inputField.value.substring(start, end);
|
selectedText = inputField.value.substring(start, end);
|
||||||
} else {
|
} else {
|
||||||
// Select the current word, find the start and end of the word (first space before and after)
|
// Select the current word, find the start and end of the word (first space before and after)
|
||||||
start = inputField.value.substring(0, start).lastIndexOf(" ") + 1;
|
const wordStart = inputField.value.substring(0, start).lastIndexOf(" ") + 1;
|
||||||
end = inputField.value.substring(end).indexOf(" ") + end;
|
const wordEnd = inputField.value.substring(end).indexOf(" ");
|
||||||
|
// If there is no space after the word, select to the end of the string
|
||||||
|
if (wordEnd === -1) {
|
||||||
|
end = inputField.value.length;
|
||||||
|
} else {
|
||||||
|
end += wordEnd;
|
||||||
|
}
|
||||||
|
start = wordStart;
|
||||||
|
|
||||||
// Remove all punctuation at the end and beginning of the word
|
// Remove all punctuation at the end and beginning of the word
|
||||||
while (inputField.value[start].match(/[.,\/#!$%\^&\*;:{}=\-_`~()]/)) {
|
while (inputField.value[start].match(/[.,\/#!$%\^&\*;:{}=\-_`~()]/)) {
|
||||||
start++;
|
start++;
|
||||||
|
Loading…
Reference in New Issue
Block a user