From 766f6e3eca38996bb291c6e891ce457671abc383 Mon Sep 17 00:00:00 2001 From: catboxanon <122327233+catboxanon@users.noreply.github.com> Date: Thu, 7 Mar 2024 18:30:36 -0500 Subject: [PATCH] edit-attention: deselect surrounding whitespace --- javascript/edit-attention.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/javascript/edit-attention.js b/javascript/edit-attention.js index 688c2f112..01069449f 100644 --- a/javascript/edit-attention.js +++ b/javascript/edit-attention.js @@ -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; }