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)

enhancement

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)
Component: Editor → Developer Tools
Product: Core → Firefox
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
(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.
(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
Priority: -- → P3
Product: Firefox → DevTools
Severity: normal → S3
Summary: prettify (combine) line break for null literals {}, [] → Don't add line break for empty object and array literals ( `{}`, `[]`)
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
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.
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 114 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: