firefox-devtools / ux

Firefox DevTools UX Community
Mozilla Public License 2.0
103 stars 21 forks source link

[Console Editor] Surface "Run Selected Code" feature #91

Open nchevobbe opened 4 years ago

nchevobbe commented 4 years ago

Related:

Since you can select only what's currently selected on the input, we might want to reflect that in the UI to indicate to the user that we'll do a specific action.

Ideas so far:

juliandescottes commented 4 years ago

Another idea:

violasong commented 4 years ago

I like Julian's idea, but I think I need to learn more about this feature. I googled "Run selected code" to see how other editors do it (e.g. VSCode) and it did involve a separate shortcut or context menu. But perhaps this feature is more relevant for a browser tool, where you might be doing more experimentation?

Keeping this in a context menu makes this feature less exposed and less discoverable, but is that a problem?

I guess the idea behind a "scratchpad" is you can write a bunch of variations of some code and test execution of each one in succession. Is this a lot more convenient than just running all the variations of the code at once? Would people use this to jot down non-executable info, or partially-written code, which they don't want to run?

cc: @digitarald @fvsch

violasong commented 4 years ago

Florens mentioned on slack:

A design pattern used by some news sites is to show floating buttons near the selection. E.g. tweeting the selected text as a quote + link. I kinda hate it to be honest (mostly because I don't need it so it just gets in the way), but it does have the advantage of making the feature more explicit.

I noticed Slack suddenly does this which I find very intense, especially with inline documentation for markdown formatting right under there, but at least it does teach you the shortcuts.

image
fvsch commented 4 years ago

Oooh are we planning Cmd+Shift+Enter to run the selected text maybe?

violasong commented 4 years ago

We definitely should if indeed we hide this into a menu :)

digitarald commented 4 years ago

Do we know how popular this is

No. It was a top-level feature in Scratchpad but did not come up in recent comments (compared to other benefits if Scratchpad. It can be a convenience to iterate on larger snippets – but we have to expose it enough to get feedback.

Overall I like the idea of a new button+shortcut to run the selected text or the current line/statement. We have enough room for "Run Selection". This would give us enough signal if people do use it, or if we should make it less prominent.

Other considerations:

Jupiter iPython Notebooks have a Run Cell pattern that is similar here. Output is shown directly below, so its not 100% comparable (closer to Scratchpad). They offer:

image

Related, Scratchpad worded this as "Display", as it does not just evaluate the current line but also displays the output. This was mostly due to the fact that Scratchpad did not output the result from the last expression; which editor mode does as it acts as console input.

Next year, eager evaluation can also provide in-context preview for output from some lines.

nchevobbe commented 4 years ago

Actually this did come up in a discussion I had with Irakli in Whistler. He was saying it was very handy when you're working on a big script ( = you want to debug only a specific part of it without wiping out everything you wrote). A specific shortcut sounds good to me + maybe some hint, somewhere (still don't know where :D )

fvsch commented 4 years ago

A specific shortcut sounds good to me + maybe some hint, somewhere (still don't know where :D )

We could:

violasong commented 4 years ago

Maybe an easy option for now is: If you select some code and hit cmd-enter or click the run button, the output starts with the explanatory line: "Running selected code:"

violasong commented 4 years ago

I do like the idea of adding this to the welcome message, if we want to encourage its usage.

digitarald commented 4 years ago

I do like the idea of adding this to the welcome message, if we want to encourage its usage.

Yes. Having some visual feedback when selecting text that execution mode changes (or a new one is available) would be great to encourage discovery (for anybody who did not read the onboarding, especially).