Closed
Bug 906640
Opened 11 years ago
Closed 11 years ago
Scratchpad does not have any script beautify/prettify function
Categories
(DevTools Graveyard :: Scratchpad, enhancement, P2)
DevTools Graveyard
Scratchpad
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 26
People
(Reporter: eldmannen+mozilla, Assigned: fitzgen)
References
Details
Attachments
(1 file, 1 obsolete file)
8.23 KB,
patch
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0 (Beta/Release) Build ID: 20130818030219 Steps to reproduce: Open Scratchpad. (Shift-F4) Wrote ugly code. Actual results: Found no beautify/prettify button or menu entry. Expected results: There should have been a beautify/prettify button or menu entry that utilized the existing jsb (JavaScript beautifier) function in Firefox available in the Developer Toolbar (Shift-F2) under the 'jsb' command.
Updated•11 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 8 → All
Hardware: x86_64 → All
Version: 26 Branch → Trunk
Assignee | ||
Comment 1•11 years ago
|
||
hello sir do you remember me? I am contacting you by bugmail https://tbpl.mozilla.org/?tree=Try&rev=f6d379c287e3
Attachment #797854 -
Flags: review?(anton)
Assignee | ||
Comment 2•11 years ago
|
||
ping
Comment 3•11 years ago
|
||
/kick
Comment 4•11 years ago
|
||
>_<
Comment 5•11 years ago
|
||
Comment on attachment 797854 [details] [diff] [review] bug-906640-scratchpad-pretty-print.patch Review of attachment 797854 [details] [diff] [review]: ----------------------------------------------------------------- Aside from one minor comment, looks good to me. ::: browser/devtools/scratchpad/scratchpad.js @@ +533,5 @@ > + const ast = Reflect.parse(uglyText); > + const prettyText = escodegen.generate(ast); > + this.setText(prettyText); > + } catch (e) { > + this.writeAsComment(DevToolsUtils.safeErrorString(e)); Why not this.writeAsErrorComment(e)?
Attachment #797854 -
Flags: review?(anton) → review+
Assignee | ||
Updated•11 years ago
|
Priority: -- → P2
Assignee | ||
Comment 6•11 years ago
|
||
Using writeAsErrorComment. Pushing to try again to see if the "extra scratchpad window" thing has fixed itself. https://tbpl.mozilla.org/?tree=Try&rev=ffe0e0b071cc
Attachment #797854 -
Attachment is obsolete: true
Assignee | ||
Comment 7•11 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/cff37b5ea5fb
Whiteboard: [fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/cff37b5ea5fb
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 26
I just tested the new "Pretty Print" button in the nightly build. It works! :) However, it strips all comments. :(
Reporter | ||
Comment 10•11 years ago
|
||
The "Pretty Print" button uses 2 space indention.
Open the Developer Toolbar (Shift+F2), type:
> jsb https://bugzilla.mozilla.org/js/yui/yahoo-dom-event/yahoo-dom-event.js
The indention used by jsb defaults to 4 spaces.
This is inconsistent. It would be desirable to be consistent.
Douglas Crockford advocates four spaces.
Google and GitHub uses two spaces.
jQuery uses tabs.
Firefox built-in jsbeautifier defaults to two spaces.
The built-in prettyprinter in Chrome and Internet Explorer uses four spaces.
Comment 11•11 years ago
|
||
Given that Scratchpad itself uses four spaces by default, we should change Pretty Print to be consistent with it and use four spaces.
Comment 12•11 years ago
|
||
(In reply to Eldmannen from comment #9) > However, it strips all comments. :( Unfortunately Reflect.parse, which parses JS into AST, does not retain information about comments. In order to keep comments, we'd also have incorporate a separate parser, like Esprima or Acorn.
Assignee | ||
Comment 13•11 years ago
|
||
Filed bug 913060 regarding indentation
Comment 14•11 years ago
|
||
escodegen cannot handle some syntax (ForOfStatement, SpreadExpression, etc), when "Pretty Print", following lines will throw for (x of [1,2,3]) console.log(x); y = [0, ...[1,2,3]];
Reporter | ||
Comment 15•11 years ago
|
||
It also strips newlines away from the code. The code: > function foo() { > } > > function bar() { > } Becomes: > function foo() { > } > function bar() { > } When using 'jsb' from the Developer Toolbar (Shift+F2) then this is not a problem. Only in Scratchpad.
Updated•6 years ago
|
Product: Firefox → DevTools
Updated•4 years ago
|
Product: DevTools → DevTools Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•