Title: [200262] trunk/Source/WebInspectorUI
Revision
200262
Author
[email protected]
Date
2016-04-29 14:08:43 -0700 (Fri, 29 Apr 2016)

Log Message

Web Inspector: Jump to Line in auto formatted _javascript_ does not work the first time
https://bugs.webkit.org/show_bug.cgi?id=157194
<rdar://problem/26008471>

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

When doing asynchronous formatting we set the content of the editor
twice. First to prime the editors back/foward list with the original
content, and then again after we get the formatted content from the
Worker, and then display the content.

The TextEditor attempts to reveal a position when the initial string
has been set. Back when autoformatting was synchronous this was fine.
Asynchronously however, this ends up happening between the original
and formatted value. Also, the TextEditor has no idea that the
SourceCodeTextEditor is going to format / defer displaying the
contents. Add a "defer" property to the TextEditor that the
SourceCodeTextEditor can use in this circumstance.

* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype._populateWithContent):
Avoid revealing a position when setting the original content. We will
be formatting and we will want to reveal the position afterwards.

* UserInterface/Views/TextEditor.js:
(WebInspector.TextEditor):
(WebInspector.TextEditor.prototype.set deferReveal):
Provide another reason to defer revealing.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (200261 => 200262)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-04-29 20:33:48 UTC (rev 200261)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-04-29 21:08:43 UTC (rev 200262)
@@ -1,3 +1,34 @@
+2016-04-29  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Jump to Line in auto formatted _javascript_ does not work the first time
+        https://bugs.webkit.org/show_bug.cgi?id=157194
+        <rdar://problem/26008471>
+
+        Reviewed by Timothy Hatcher.
+
+        When doing asynchronous formatting we set the content of the editor
+        twice. First to prime the editors back/foward list with the original
+        content, and then again after we get the formatted content from the
+        Worker, and then display the content.
+
+        The TextEditor attempts to reveal a position when the initial string
+        has been set. Back when autoformatting was synchronous this was fine.
+        Asynchronously however, this ends up happening between the original
+        and formatted value. Also, the TextEditor has no idea that the
+        SourceCodeTextEditor is going to format / defer displaying the
+        contents. Add a "defer" property to the TextEditor that the
+        SourceCodeTextEditor can use in this circumstance.
+
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WebInspector.SourceCodeTextEditor.prototype._populateWithContent):
+        Avoid revealing a position when setting the original content. We will
+        be formatting and we will want to reveal the position afterwards.
+
+        * UserInterface/Views/TextEditor.js:
+        (WebInspector.TextEditor):
+        (WebInspector.TextEditor.prototype.set deferReveal):
+        Provide another reason to defer revealing.
+
 2016-04-28  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: FormatterWorker fails to find "External/Esprima.js" in Production builds

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (200261 => 200262)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js	2016-04-29 20:33:48 UTC (rev 200261)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js	2016-04-29 21:08:43 UTC (rev 200262)
@@ -394,7 +394,9 @@
         if (this._autoFormat) {
             console.assert(!this.formatted);
             this._autoFormat = false;
+            this.deferReveal = true;
             this.string = content;
+            this.deferReveal = false;
             this.updateFormattedState(true).then(() => {
                 this._proceedPopulateWithContent(this.string);
             });

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (200261 => 200262)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2016-04-29 20:33:48 UTC (rev 200261)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2016-04-29 21:08:43 UTC (rev 200262)
@@ -66,6 +66,7 @@
         this._formatted = false;
         this._formattingPromise = null;
         this._formatterSourceMap = null;
+        this._deferReveal = false;
 
         this._delegate = delegate || null;
     }
@@ -254,6 +255,11 @@
         }
     }
 
+    set deferReveal(defer)
+    {
+        this._deferReveal = defer;
+    }
+
     performSearch(query)
     {
         if (this._searchQuery === query)
@@ -423,7 +429,7 @@
             return;
 
         var lineHandle = this._codeMirror.getLineHandle(position.lineNumber);
-        if (!lineHandle || !this._visible || this._initialStringNotSet) {
+        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;
             this._textRangeToSelect = textRangeToSelect;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to