Bug 147918

Summary: Web Inspector: Pressing Command-Enter should re-evaluate selected console user command
Product: WebKit Reporter: Nikita Vasilyev <nvasilyev>
Component: Web InspectorAssignee: Nikita Vasilyev <nvasilyev>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, graouts, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[Animated GIF] Option-Click to re-run
none
Patch
none
[Animated GIF] Re-submit on click
none
[Animated GIF] With the patch applied
none
Patch
nvasilyev: review-, nvasilyev: commit-queue-
Patch none

Description Nikita Vasilyev 2015-08-11 19:19:17 PDT
Created attachment 258792 [details]
[Animated GIF] Option-Click to re-run

See the attached GIF.

Note that we don't attach Math.random() row on every click because it matches the last user command. However, in the following example:

    > Math.random()
    < 0.4242424242
    > document.location.pathname
    < "/"

clicking Math.random() should attach it again, e.g.:

    > Math.random()
    < 0.4242424242
    > document.location.pathname
    < "/"
    > Math.random()
    > 0.2354678908

Also, Command+Enter, Option-Enter, or both should re-evaluate selected console message.
Comment 1 Timothy Hatcher 2015-08-11 20:52:39 PDT
I like!  I agree Command or Option-Enter on the selected row should do this too.
Comment 2 Timothy Hatcher 2015-08-11 20:53:09 PDT
Or maybe just Enter for selected row?
Comment 3 Timothy Hatcher 2015-08-11 22:26:58 PDT
Lets also make the double arrow that appears more like the existing grey arrow. So same size/shape but double and blue.
Comment 4 Radar WebKit Bug Importer 2015-08-16 00:20:56 PDT
<rdar://problem/22300296>
Comment 5 Nikita Vasilyev 2015-08-16 00:32:04 PDT
Created attachment 259115 [details]
Patch
Comment 6 Nikita Vasilyev 2015-08-16 00:53:34 PDT
Created attachment 259116 [details]
[Animated GIF] Re-submit on click

I implemented re-submit on click and run it for a day. It turned out not as useful as I have thought because:
1. Console messages shift up every time a new one is added — I need to move mouse cursor after every click.
2. Console always scrolls to the bottom when the new user command result is added, as it should be, but it often leaves the clicked user command out of the view port.

In the attached patch I only implemented re-submit on Enter. I want to give Option-Click to re-run a bit more thought and not include it in this patch.
Comment 7 Nikita Vasilyev 2015-08-16 01:01:50 PDT
Created attachment 259117 [details]
[Animated GIF] With the patch applied
Comment 8 Devin Rousso 2015-08-17 16:49:46 PDT
Comment on attachment 259115 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259115&action=review

> Source/WebInspectorUI/UserInterface/Views/LogContentView.js:828
> +        var message = this._selectedMessages[0];

Let instead of var.

> Source/WebInspectorUI/UserInterface/Views/LogContentView.js:839
> +            if (consoleItemElement.__commandView) {

We should change this from "__" to a symbol (can be a different patch, but should be done).

> Source/WebInspectorUI/UserInterface/Views/LogContentView.js:861
> +            WebInspector.logManager.dispatchEventToListeners(WebInspector.LogManager.Event.MessageAdded, {message: commandResultMessage});

Won't this event be triggered once the new command has been executed and added to the frontend, or is it necessary to fire MessageAdded before the message is actually added?
Comment 9 Nikita Vasilyev 2015-08-17 17:09:51 PDT
Comment on attachment 259115 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259115&action=review

>> Source/WebInspectorUI/UserInterface/Views/LogContentView.js:861
>> +            WebInspector.logManager.dispatchEventToListeners(WebInspector.LogManager.Event.MessageAdded, {message: commandResultMessage});
> 
> Won't this event be triggered once the new command has been executed and added to the frontend, or is it necessary to fire MessageAdded before the message is actually added?

Removing this line would prevent the result from being added to the console.
It looks like I could use this._logViewController.appendConsoleMessage instead.
Comment 10 Nikita Vasilyev 2015-08-17 21:19:17 PDT
Created attachment 259237 [details]
Patch
Comment 11 Nikita Vasilyev 2015-08-18 00:27:44 PDT
Comment on attachment 259237 [details]
Patch

Since https://bugs.webkit.org/show_bug.cgi?id=148121, pressing Enter when a console message is selected behaves the same way as pressing Enter in the console prompt. I think this is right.

We should be consistent with "Web Inspector: Option-Enter should commit console command without erasing the prompt" https://bugs.webkit.org/show_bug.cgi?id=148123 and use the same shortcut. I used Option–Enter there but I'm open to suggestions.
Comment 12 Nikita Vasilyev 2015-08-18 23:39:01 PDT
Created attachment 259363 [details]
Patch

Rebaselined and significantly simplified.
Comment 13 WebKit Commit Bot 2015-08-19 02:35:44 PDT
Comment on attachment 259363 [details]
Patch

Clearing flags on attachment: 259363

Committed r188637: <http://trac.webkit.org/changeset/188637>
Comment 14 WebKit Commit Bot 2015-08-19 02:35:50 PDT
All reviewed patches have been landed.  Closing bug.