edit-attention: deselect surrounding whitespace

This commit is contained in:
catboxanon 2024-03-07 18:30:36 -05:00 committed by GitHub
parent 58f7410c9d
commit 766f6e3eca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -64,6 +64,14 @@ function keyupEditAttention(event) {
selectionEnd++;
}
// deselect surrounding whitespace
while (target.value.slice(selectionStart, selectionStart + 1) == " " && selectionStart < selectionEnd) {
selectionStart++;
}
while (target.value.slice(selectionEnd - 1, selectionEnd) == " " && selectionEnd > selectionStart) {
selectionEnd--;
}
target.setSelectionRange(selectionStart, selectionEnd);
return true;
}