فهرست منبع

Correctly remove end parenthesis with ctrl+up/down

missionfloyd 2 سال پیش
والد
کامیت
0b0767939d
1فایلهای تغییر یافته به همراه3 افزوده شده و 2 حذف شده
  1. 3 2
      javascript/edit-attention.js

+ 3 - 2
javascript/edit-attention.js

@@ -100,11 +100,12 @@ function keyupEditAttention(event) {
     if (String(weight).length == 1) weight += ".0";
 
     if (closeCharacter == ')' && weight == 1) {
-        text = text.slice(0, selectionStart - 1) + text.slice(selectionStart, selectionEnd) + text.slice(selectionEnd + 5);
+        var endParenPos = text.substring(selectionEnd).indexOf(')');
+        text = text.slice(0, selectionStart - 1) + text.slice(selectionStart, selectionEnd) + text.slice(selectionEnd + endParenPos + 1);
         selectionStart--;
         selectionEnd--;
     } else {
-        text = text.slice(0, selectionEnd + 1) + weight + text.slice(selectionEnd + 1 + end - 1);
+        text = text.slice(0, selectionEnd + 1) + weight + text.slice(selectionEnd + end);
     }
 
     target.focus();