Bug 148368 - Web Inspector: Command-Enter should evaluate selected JS in Debugger/Sources
Summary: Web Inspector: Command-Enter should evaluate selected JS in Debugger/Sources
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Nikita Vasilyev
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-08-22 20:27 PDT by Nikita Vasilyev
Modified: 2015-09-14 01:55 PDT (History)
8 users (show)

See Also:


Attachments
Patch (2.63 KB, patch)
2015-08-26 02:45 PDT, Nikita Vasilyev
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2015-08-22 20:27:18 PDT
Light Table has an inline evaluation. Pressing Command-Enter runs the selected code and shows the return value inline, right by the code.
http://lighttable.com/#features

Chrome DevTools have a Control-Shift-E shortcut to evaluate selected text in the console.

I think, eventually we need to do something like Light Table. There are quite a few nuances and I could take while to get it right. So, for now, I propose to implement Command-Enter shortcut to evaluate the selected code in the console.
Comment 1 Radar WebKit Bug Importer 2015-08-22 20:27:46 PDT
<rdar://problem/22393224>
Comment 2 Nikita Vasilyev 2015-08-26 02:45:58 PDT
Created attachment 259942 [details]
Patch
Comment 3 Timothy Hatcher 2015-08-26 02:51:03 PDT
Comment on attachment 259942 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js:730
> +        if (modeName !== "javascript" && modeName !== "htmlmixed")

I think there is a way to get the inner mode for the selection, that way we know if it is JS even inside html. Right now I think that will allow non-JS to be evaluated from HTML. The completion controller has code for looking at inner mode I think.
Comment 4 Timothy Hatcher 2015-08-26 02:51:26 PDT
Comment on attachment 259942 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js:730
>> +        if (modeName !== "javascript" && modeName !== "htmlmixed")
> 
> I think there is a way to get the inner mode for the selection, that way we know if it is JS even inside html. Right now I think that will allow non-JS to be evaluated from HTML. The completion controller has code for looking at inner mode I think.

Oh, now I see your comment in the ChangeLog. Sounds good.
Comment 5 Nikita Vasilyev 2015-08-26 02:57:20 PDT
(In reply to comment #4)
> Comment on attachment 259942 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=259942&action=review
> 
> >> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js:730
> >> +        if (modeName !== "javascript" && modeName !== "htmlmixed")
> > 
> > I think there is a way to get the inner mode for the selection, that way we know if it is JS even inside html. Right now I think that will allow non-JS to be evaluated from HTML. The completion controller has code for looking at inner mode I think.
> 
> Oh, now I see your comment in the ChangeLog. Sounds good.

Currently, pressing Command-Enter inside a resource doesn't do anything at all. It doesn't insert a new line. We may revisit what does it do for HTML in the future, but I don't have any other ideas at the moment.
Comment 6 WebKit Commit Bot 2015-08-26 09:06:38 PDT
Comment on attachment 259942 [details]
Patch

Clearing flags on attachment: 259942

Committed r188967: <http://trac.webkit.org/changeset/188967>
Comment 7 WebKit Commit Bot 2015-08-26 09:06:46 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Nikita Vasilyev 2015-09-14 01:55:33 PDT
Looking into this two weeks later with a fresh eye, I think Command-Enter should show the exact same popover as on hover. Evaluating in the console seems too disconnected from the source code and requires a bit of an extra mental effort not to lose the context.