Title: [196003] trunk/Source/WebInspectorUI
Revision
196003
Author
[email protected]
Date
2016-02-01 22:15:59 -0800 (Mon, 01 Feb 2016)

Log Message

Web Inspector: Option+Up/Down should not move cursor outside of number
https://bugs.webkit.org/show_bug.cgi?id=153784
<rdar://problem/24453133>

Patch by Joseph Pecoraro <[email protected]> on 2016-02-01
Reviewed by Timothy Hatcher.

* UserInterface/Views/CodeMirrorAdditions.js:
When selectionStart === selectionEnd we were duplicating the
movement mutation by performing it twice on the same object.
After much experimentation, I left in the existing code path
for handling mutation with a selection. It is not perfect,
but it is better then just applying the ch diff.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (196002 => 196003)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-02-02 06:12:38 UTC (rev 196002)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-02-02 06:15:59 UTC (rev 196003)
@@ -1,5 +1,20 @@
 2016-02-01  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: Option+Up/Down should not move cursor outside of number
+        https://bugs.webkit.org/show_bug.cgi?id=153784
+        <rdar://problem/24453133>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/CodeMirrorAdditions.js:
+        When selectionStart === selectionEnd we were duplicating the
+        movement mutation by performing it twice on the same object.
+        After much experimentation, I left in the existing code path
+        for handling mutation with a selection. It is not perfect,
+        but it is better then just applying the ch diff.
+
+2016-02-01  Joseph Pecoraro  <[email protected]>
+
         Web Inspector: High Level Memory Overview Instrument
         https://bugs.webkit.org/show_bug.cgi?id=153516
         <rdar://problem/24356378>

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js (196002 => 196003)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js	2016-02-02 06:12:38 UTC (rev 196002)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js	2016-02-02 06:15:59 UTC (rev 196003)
@@ -484,12 +484,17 @@
             var newLength = alteredNumberString.length;
 
             // Fix up the selection so it follows the increase or decrease in the replacement length.
-            if (previousLength !== newLength) {
-                if (selectionStart.line === from.line && selectionStart.ch > from.ch)
-                    selectionStart.ch += newLength - previousLength;
-
-                if (selectionEnd.line === from.line && selectionEnd.ch > from.ch)
-                    selectionEnd.ch += newLength - previousLength;
+            // selectionStart/End may the same object if there is no selection. If that is the case
+            // make only one modification to prevent a double adjustment, and keep it a single object
+            // to avoid CodeMirror inadvertently creating an actual selection range.
+            let diff = (newLength - previousLength);
+            if (selectionStart === selectionEnd)
+                selectionStart.ch += diff;
+            else {
+                if (selectionStart.ch > from.ch)
+                    selectionStart.ch += diff;
+                if (selectionEnd.ch > from.ch)
+                    selectionEnd.ch += diff;
             }
 
             this.setSelection(selectionStart, selectionEnd);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to