Closed
Bug 1242729
Opened 10 years ago
Closed 3 years ago
Don't add line break for empty object and array literals ( `{}`, `[]`)
Categories
(DevTools :: Source Editor, enhancement, P3)
DevTools
Source Editor
Tracking
(firefox114 fixed)
RESOLVED
FIXED
114 Branch
| Tracking | Status | |
|---|---|---|
| firefox114 | --- | fixed |
People
(Reporter: pavel.kostenkov, Assigned: nchevobbe)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20160124004010
Steps to reproduce:
Just open dev tools with some minified source and click "prettify" on the bottom.
Got the issue on 45 but probably it could exist in any previous stable version.
Actual results:
Looks like it prettifies simply by injecting line break after { or [. I am not sure if this should be applicable for object literals in constructions like this:
var a = {};
var b = [];
Internal prettifier makes those:
var a = {
};
var b = [
];
Expected results:
should be var a = {}, b = [] (no line break for literals without keys/values)
Updated•10 years ago
|
Component: Editor → Developer Tools
Product: Core → Firefox
Updated•10 years ago
|
Component: Developer Tools → Developer Tools: Source Editor
Coul you attach a simple minified source file as testcase, please.
Flags: needinfo?(pavel.kostenkov)
(In reply to Loic from comment #1)
> Coul you attach a simple minified source file as testcase, please.
The simple stub like this is enough:
<script src='https://code.jquery.com/jquery-1.12.0.min.js'></script>
Not sure would this make any help if I attach minified jquery
Comment 3•10 years ago
|
||
(In reply to PK from comment #0)
> Looks like it prettifies simply by injecting line break after { or [. I am
> not sure if this should be applicable for object literals in constructions
> like this:
> var a = {};
> var b = [];
> Internal prettifier makes those:
> var a = {
> };
> var b = [
> ];
>
>
>
> Expected results:
>
> should be var a = {}, b = [] (no line break for literals without keys/values)
I'm not sure about pushing them onto one line and removing the second var, but I agree that adding a new line for empty object / array literals seems off.
Given
var a = {};
var b = [];
I think the prettifier should just leave it alone. Nick, any opinion?
Flags: needinfo?(nfitzgerald)
(In reply to Brian Grinstead [:bgrins] from comment #3)
> (In reply to PK from comment #0)
> > Looks like it prettifies simply by injecting line break after { or [. I am
> > not sure if this should be applicable for object literals in constructions
> > like this:
> > var a = {};
> > var b = [];
> > Internal prettifier makes those:
> > var a = {
> > };
> > var b = [
> > ];
> >
> >
> >
> > Expected results:
> >
> > should be var a = {}, b = [] (no line break for literals without keys/values)
>
> I'm not sure about pushing them onto one line and removing the second var,
> but I agree that adding a new line for empty object / array literals seems
> off.
>
> Given
> var a = {};
> var b = [];
>
> I think the prettifier should just leave it alone. Nick, any opinion?
No need to push on one line vars, just to remove line break between [ ] and {} when there are no keys/values.
Comment 5•10 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #3)
> Given
> var a = {};
> var b = [];
>
> I think the prettifier should just leave it alone. Nick, any opinion?
Sure, if we can do it without slowing down the prettifier or complicating its logic.
The goal of the prettifier was never to produce beautiful code as you would have written it -- it was to be fast despite generating source maps, and produce readable output.
Flags: needinfo?(nfitzgerald)
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(pavel.kostenkov)
Summary: prettify line break for literals {}, [] → prettify (combine) line break for null literals {}, []
Version: 45 Branch → Trunk
Updated•9 years ago
|
Blocks: dbg-prettyprint
Priority: -- → P3
Updated•8 years ago
|
Product: Firefox → DevTools
Updated•3 years ago
|
Severity: normal → S3
| Assignee | ||
Updated•3 years ago
|
Summary: prettify (combine) line break for null literals {}, [] → Don't add line break for empty object and array literals ( `{}`, `[]`)
| Assignee | ||
Comment 6•3 years ago
|
||
Depends on D174281
Updated•3 years ago
|
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
| Assignee | ||
Comment 7•3 years ago
|
||
Depends on D174946
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ddda87f27af5
[devtools] Don't add new line for empty array literal. r=devtools-reviewers,ochameau.
https://hg.mozilla.org/integration/autoland/rev/be68826cf661
[devtools] Don't add new line for empty object literal. r=devtools-reviewers,ochameau.
Comment 9•3 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/ddda87f27af5
https://hg.mozilla.org/mozilla-central/rev/be68826cf661
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
status-firefox114:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 114 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•