aboutsummaryrefslogtreecommitdiff
path: root/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'javascript')
-rw-r--r--javascript/edit-attention.js5
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);