Browse Source

edit-attention: deselect surrounding whitespace

catboxanon 1 năm trước cách đây
mục cha
commit
766f6e3eca
1 tập tin đã thay đổi với 8 bổ sung0 xóa
  1. 8 0
      javascript/edit-attention.js

+ 8 - 0
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;
     }