Bug 19931 - Input should be printed before the output in the console
Summary: Input should be printed before the output in the console
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Timothy Hatcher
URL: wwf
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-07 12:38 PDT by Anthony Ricaud
Modified: 2009-03-02 00:23 PST (History)
3 users (show)

See Also:


Attachments
initial prototype (3.87 KB, patch)
2008-07-07 18:51 PDT, Keishi Hattori
aroben: review-
Details | Formatted Diff | Diff
screenshot (16.24 KB, patch)
2008-07-07 18:56 PDT, Keishi Hattori
no flags Details | Formatted Diff | Diff
better screenshot (20.93 KB, image/png)
2008-07-07 18:59 PDT, Keishi Hattori
no flags Details
Original Design (2.09 KB, image/png)
2008-07-08 09:27 PDT, Timothy Hatcher
no flags Details
Fixed change log (4.20 KB, patch)
2008-07-09 18:29 PDT, Keishi Hattori
no flags Details | Formatted Diff | Diff
Proposed Patch (9.51 KB, patch)
2009-02-28 15:28 PST, Timothy Hatcher
oliver: review+
Details | Formatted Diff | Diff
Screenshot of new design (8.48 KB, image/png)
2009-02-28 15:28 PST, Timothy Hatcher
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Ricaud 2008-07-07 12:38:51 PDT
Like in Firebug and other "shells", the input should be printed before the output.

Actual behaviour :
foo enter_bug.cgi
> console.log('foo')

Desired behaviour :
> console.log('foo')
foo enter_bug.cgi
Comment 1 Keishi Hattori 2008-07-07 18:51:27 PDT
Created attachment 22148 [details]
initial prototype

Here is a quick patch to see what it might look. 

We could add "if (typeof result === "undefined") return;" to match Firebug completely and not print assigned undefineds.
Comment 2 Keishi Hattori 2008-07-07 18:56:29 PDT
Created attachment 22149 [details]
screenshot

screenshot of patch in action
Comment 3 Keishi Hattori 2008-07-07 18:59:53 PDT
Created attachment 22150 [details]
better screenshot
Comment 4 Anthony Ricaud 2008-07-07 23:09:43 PDT
Thanks, it looks really better.

For undefined, let's talk in bug 19932.
Comment 5 Adam Roben (:aroben) 2008-07-08 07:16:37 PDT
Comment on attachment 22148 [details]
initial prototype

+        Fix for https://bugs.webkit.org/show_bug.cgi?id=19931

We usually include the title of the bug, then the URL, like this:

Fix Bug 19931: Input should be printed before the output in the console

<https://bugs.webkit.org/show_bug.cgi?id=19931>

+        * page/inspector/Console.js: Console command line input gets printed immediately.

We normally try to describe the actual changes made here, not what the problem was that inspired the changes. We also try to break up the changes by function, like this:

(WebInspector.Console.prototype._enterKeyPressed): Split the input/output into two pieces. The input is added to the console before it is evaluated. After evaluation the output is added.

+WebInspector.ConsoleCommandResult = function(command, result, formattedResultElement, level)
+{
+    this.command = command;

I don't think we need to pass in and store the command here.

I think ConsoleCommandInput and ConsoleCommandOutput would be better names fro these types than ConsoleCommand and ConsoleCommandResult. What do you think?

I guess there's a chance that some styling will change as a result of this, but it looks like the common cases stay the same.

r- so that the ChangeLog can be fixed up and the new names can be considered. Looking good!
Comment 6 Timothy Hatcher 2008-07-08 09:26:42 PDT
(In reply to comment #5)
> I guess there's a chance that some styling will change as a result of this, but
> it looks like the common cases stay the same.

The styling did change. There is now a divider line between the input and output, which I think makes the output look confusing and was avoided in the original design. See the attached screenshot.
Comment 7 Timothy Hatcher 2008-07-08 09:27:08 PDT
Created attachment 22158 [details]
Original Design
Comment 8 Timothy Hatcher 2008-07-08 11:41:27 PDT
It is not clear where the line that logs the function result came from. Sometimes it is after any console.logs() that the function did, or it is the line right after the input. Look at the screenshot in bug 19931, and you see:

> console.log("hi")
---------
"hi"
---------
undefined

That undefined could be a console.log(undefined). The result is not clearly marked.

I think we need to mark function result lines some how. Or keep the input and function result grouped, but insert the input into the console before the function executes then update the input with the result.

So:

> console.log("hi")
    undefined
--------
    "hi"

Comment 9 Keishi Hattori 2008-07-09 18:29:24 PDT
Created attachment 22196 [details]
Fixed change log

I fixed the change log.
Comment 10 Anthony Ricaud 2008-08-05 17:00:25 PDT
What about something like that :

>  console.log("hi")
     "hi"
->undefined

with -> an arrow like the one in Mail.app when you answer a mail (but reversed).

You get the same visual order as the order that things happen and you have a visual distinction between console.log output and result.
Comment 11 Timothy Hatcher 2008-08-06 09:34:50 PDT
(In reply to comment #10)
> What about something like that :
> 
> >  console.log("hi")
>      "hi"
> ->undefined
> 
> with -> an arrow like the one in Mail.app when you answer a mail (but
> reversed).
> 
> You get the same visual order as the order that things happen and you have a
> visual distinction between console.log output and result.
> 

That might be enough! Maybe clicking the "curled arrow" would scroll to and highlight the original function call for a couple of seconds. THat way, if there is lots of console.logging in the function, you can find the original call quickly.
Comment 12 Timothy Hatcher 2009-02-28 15:28:25 PST
Created attachment 28127 [details]
Proposed Patch
Comment 13 Timothy Hatcher 2009-02-28 15:28:55 PST
Created attachment 28128 [details]
Screenshot of new design
Comment 14 Timothy Hatcher 2009-03-02 00:23:30 PST
Fixed in r41352.