Scratchpad Inspect should show non-objects in inspector, not comments

RESOLVED FIXED in Firefox 33

Status

DevTools
Scratchpad
RESOLVED FIXED
4 years ago
a month ago

People

(Reporter: Florens Verschelde, Assigned: past)

Tracking

unspecified
Firefox 33
x86
Mac OS X

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

4 years ago
(A bit of a lenghty introduction. This is a usability bug, so it requires some context and explanations.)

Context: I've only used Scratchpad a few times, mostly treating it as a JavaScript console with multiline input (which the console in Fx devtools doesn’t have). After using it maybe a dozen times over the course of a few weeks, and not really getting how it works exactly, I finally figured out one thing (among several) that puzzled me and made it harder for me to understand what Scratchpad is and how it works, and to feel confident in using it.

Namely: The “Inspect” feature doesn’t work as advertised (in the intro comment). Half of the time it does exactly the same thing as the “Display” feature.

This is how the Inspect and Display features are advertised:
> 2. Inspect to bring up an Object Inspector on the result (Cmd-I), or,
> 3. Display to insert the result in a comment after the selection. (Cmd-L)

Inspect -> Object Inspector. Display -> comment. Got it.
But it doesn’t work that way.

Here’s how the “Inspect” feature actually works:

- Code that returns an object -> Inspector
- Code that returns an array -> Inspector
- Code that returns a function -> Inspector
- Code that returns a string -> COMMENT (like Display)
- Code that returns undefined or null -> COMMENT (like Display)
- Code that returns a number or NaN -> COMMENT (like Display)
- Code that yields an exception -> COMMENT (like Display)

Half the use cases of “inspecting something” or even more (accounting for a lot of syntax errors and other exceptions, bad selections, etc.) will not do what Scratchpad says “Inspect” is for.

I suspect that a lot of confusion ensues, and that it’s one of the top 5 issues that make adoption of Scratchpad harder.

How to fix this one:
Inspect should always show results in the Object Inspector pane. Even if the results are NOT objects. The point here is that the behavior of “Inspect” should be predictable, and always show the end result in the same location.
(Reporter)

Comment 1

4 years ago
Created attachment 8442523 [details]
Quick mock-up

Screenshot showing the Object Inspector (top) for a function, and a proposed output box for primitives (bottom) occupying the same panel.

Ideally the panel would have a header stating what we’re inspecting or outputting. So in those two examples we would have:
- "function test()" (same styling as the console)
- "string" (instead of "Output" in my mock-up)
I argued for removing display and only having inspect, but robcee was against it. I forget his reasoning why.

I'm still for it, and I think we could kill two birds with one stone here...
Flags: needinfo?(rcampbell)
Status: UNCONFIRMED → NEW
Ever confirmed: true
I'm not sure who implemented this behavior, but my guess is that the thought must have been that an inline comment is more "lightweight". That's certainly how I perceive them, but I can see how it would be confusing to most devs who are more familiar with an object inspector.

(In reply to Florent Verschelde from comment #0)
> Context: I've only used Scratchpad a few times, mostly treating it as a
> JavaScript console with multiline input (which the console in Fx devtools
> doesn’t have).

As an aside, you can use Shift-Enter to get a multiline console:
https://developer.mozilla.org/docs/Tools/Web_Console#Entering_expressions
Created attachment 8442733 [details] [diff] [review]
Inspect primitive values in the object inspector instead of as inline comments

To be honest I like using the Display shortcut for quick inspection and the Inspect shortcut for more involved ones. And fixing the inconsistency noted in this bug is fairly simple, but let's see what Rob thinks.
Attachment #8442733 - Flags: review?(rcampbell)
Assignee: nobody → past
Status: NEW → ASSIGNED
(Reporter)

Comment 5

4 years ago
(In reply to Panos Astithas [:past] from comment #3)
> I'm not sure who implemented this behavior, but my guess is that the thought
> must have been that an inline comment is more "lightweight".

It might be Bug 690552.
(I don’t know whether this bug included the "Inspect" feature. In some execution modes when the result was an exception it went to the Error Console or Web Console, and it was changed so that exceptions would be written as comments in the scratchpad instead.)
an inline comment is easy to use, easy to implement and easy to copy and paste elsewhere. Adding an "output" panel is going to open up a slew of follow-up bugs to implement all of our nice formatting features from the web console and elsewhere. It also blurs the lines between the scratchpad and the console.

I still don't like this.
Flags: needinfo?(rcampbell)
Comment on attachment 8442733 [details] [diff] [review]
Inspect primitive values in the object inspector instead of as inline comments

Does this need a test?
Attachment #8442733 - Flags: review?(rcampbell) → review+
Created attachment 8444422 [details] [diff] [review]
Inspect primitive values in the object inspector instead of as inline comments v2

Yep, here is a test.
Try: https://tbpl.mozilla.org/?tree=Try&rev=4ffa00b643cb
Attachment #8442733 - Attachment is obsolete: true
(Reporter)

Comment 9

4 years ago
(In reply to Rob Campbell [:rc] (:robcee) from comment #6)
> Adding an "output" panel is going to open up a slew of
> follow-up bugs to implement all of our nice formatting features from the web
> console and elsewhere.

Is it probable that there would be many such requests? And couldn't they be WONTFIXed easily ("As of now we have no plans to extend that part of Scratchpad. You can use X instead."), if need be?

I'd suggest not using a generic heading such as "Output" ("An Output pane in Scratchpad? Let's do a bucketload of new stuff with it!"), and instead using the result's type (or nothing).

    string
    "the string"

    number
    421

> It also blurs the lines between the scratchpad and the console.

Perhaps, but isn’t the line blurred by the availability of an “Inspect” function (and the same Object Inspector as in the console) to begin with? Not sure this changes anything in that respect.
https://hg.mozilla.org/mozilla-central/rev/0701ea0bfaf6
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 33

Updated

a month ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.