Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
0be92710
Commit
0be92710
authored
Apr 21, 2023
by
comfyanonymous
Browse files
Merge branch 'currentword-select' of
https://github.com/missionfloyd/ComfyUI
parents
907010e0
d2ef3465
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
16 deletions
+9
-16
web/extensions/core/editAttention.js
web/extensions/core/editAttention.js
+9
-16
No files found.
web/extensions/core/editAttention.js
View file @
0be92710
...
...
@@ -89,24 +89,17 @@ app.registerExtension({
end
=
nearestEnclosure
.
end
;
selectedText
=
inputField
.
value
.
substring
(
start
,
end
);
}
else
{
// Select the current word, find the start and end of the word (first space before and after)
const
wordStart
=
inputField
.
value
.
substring
(
0
,
start
).
lastIndexOf
(
"
"
)
+
1
;
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
;
// Select the current word, find the start and end of the word
const
delimiters
=
"
.,
\\
/!?%^*;:{}=-_`~()
\r\n\t
"
;
// Remove all punctuation at the end and beginning of the word
while
(
inputField
.
value
[
start
].
match
(
/
[
.,
\/
#!$%
\^
&
\*
;:{}=
\-
_`~()
]
/
))
{
start
++
;
while
(
!
delimiters
.
includes
(
inputField
.
value
[
start
-
1
])
&&
start
>
0
)
{
start
--
;
}
while
(
inputField
.
value
[
end
-
1
].
match
(
/
[
.,
\/
#!$%
\^
&
\*
;:{}=
\-
_`~()
]
/
))
{
end
--
;
while
(
!
delimiters
.
includes
(
inputField
.
value
[
end
])
&&
end
<
inputField
.
value
.
length
)
{
end
++
;
}
selectedText
=
inputField
.
value
.
substring
(
start
,
end
);
if
(
!
selectedText
)
return
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment