Web Inspector: REGRESSION (r195723): Improve support for resources with '\r' and...
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jul 2018 23:11:08 +0000 (23:11 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jul 2018 23:11:08 +0000 (23:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186453
<rdar://problem/39689180>

Reviewed by Joseph Pecoraro.

Now that the frontend no longer uses offsets from the original source
file to calculate positions within CodeMirror, it is possible to support
resources with '\r' and '\r\n' line endings in the editor.

* UserInterface/Views/CodeMirrorEditor.js:
(WI.CodeMirrorEditor.create):
(WI.CodeMirrorEditor):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233824 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js

index 1f011b1..4200548 100644 (file)
@@ -1,5 +1,21 @@
 2018-07-13  Matt Baker  <mattbaker@apple.com>
 
+        Web Inspector: REGRESSION (r195723): Improve support for resources with '\r' and '\r\n' line endings
+        https://bugs.webkit.org/show_bug.cgi?id=186453
+        <rdar://problem/39689180>
+
+        Reviewed by Joseph Pecoraro.
+
+        Now that the frontend no longer uses offsets from the original source
+        file to calculate positions within CodeMirror, it is possible to support
+        resources with '\r' and '\r\n' line endings in the editor.
+
+        * UserInterface/Views/CodeMirrorEditor.js:
+        (WI.CodeMirrorEditor.create):
+        (WI.CodeMirrorEditor):
+
+2018-07-13  Matt Baker  <mattbaker@apple.com>
+
         Web Inspector: Basic blocks highlighting should use line/column locations instead of offsets
         https://bugs.webkit.org/show_bug.cgi?id=187613
         <rdar://problem/42131808>
index a0338c2..d0636f3 100644 (file)
@@ -27,8 +27,9 @@ WI.CodeMirrorEditor = class CodeMirrorEditor
 {
     static create(element, options)
     {
+        // Default line endings match typical expected line endings for JavaScript (at least those supported by JavaScriptCore).
         if (options.lineSeparator === undefined)
-            options.lineSeparator = "\n";
+            options.lineSeparator = /\r\n?|\n/;
 
         // CodeMirror's manual scrollbar positioning results in double scrollbars,
         // nor does it handle braces and brackets well, so default to using LTR.