Web Inspector: Entering ":n" in Open Resource Dialog, where n > number of lines,...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Aug 2016 05:12:32 +0000 (05:12 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Aug 2016 05:12:32 +0000 (05:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160840

Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-08-22
Reviewed by Joseph Pecoraro.

* UserInterface/Views/TextEditor.js:
(TextEditor.prototype.revealPosition):
Limit the given line and column to the maximum number of lines and the column count on the
resulting line.

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

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

index e8aab9c7b28ae242d4c90261fc8d3a9306145377..1cc97ba7cf927bffc732558cda99c924c9c78cc5 100644 (file)
@@ -1,3 +1,15 @@
+2016-08-22  Devin Rousso  <dcrousso+webkit@gmail.com>
+
+        Web Inspector: Entering ":n" in Open Resource Dialog, where n > number of lines, should jump to the last line
+        https://bugs.webkit.org/show_bug.cgi?id=160840
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/TextEditor.js:
+        (TextEditor.prototype.revealPosition):
+        Limit the given line and column to the maximum number of lines and the column count on the
+        resulting line.
+
 2016-08-22  Devin Rousso  <dcrousso+webkit@gmail.com>
 
         Web Inspector: Add indicator to matched selector being a pseudo-element
index 2c80904e251b02ed1cb73ed07dfcc5a1b4734647..72a1520725fe0a6ab6ca8c7c4b3be3f7f4dec82b 100644 (file)
@@ -428,7 +428,7 @@ WebInspector.TextEditor = class TextEditor extends WebInspector.View
         if (!(position instanceof WebInspector.SourceCodePosition))
             return;
 
-        var lineHandle = this._codeMirror.getLineHandle(position.lineNumber);
+        let lineHandle = this._codeMirror.getLineHandle(position.lineNumber);
         if (!lineHandle || !this._visible || this._initialStringNotSet || this._deferReveal) {
             // If we can't get a line handle or are not visible then we wait to do the reveal.
             this._positionToReveal = position;
@@ -451,8 +451,14 @@ WebInspector.TextEditor = class TextEditor extends WebInspector.View
             return;
         }
 
-        if (!textRangeToSelect)
-            textRangeToSelect = new WebInspector.TextRange(position.lineNumber, position.columnNumber, position.lineNumber, position.columnNumber);
+        let line = Number.constrain(position.lineNumber, 0, this._codeMirror.lineCount() - 1);
+        if (line !== position.lineNumber)
+            lineHandle = this._codeMirror.getLineHandle(line);
+
+        if (!textRangeToSelect) {
+            let column = Number.constrain(position.columnNumber, 0, this._codeMirror.getLine(line).length - 1);
+            textRangeToSelect = new WebInspector.TextRange(line, column, line, column);
+        }
 
         function removeStyleClass()
         {