This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 217695

Summary: Reformatting should not split small hashes
Product: javascript Reporter: _ tboudreau <tboudreau>
Component: EditorAssignee: Petr Pisl <ppisl>
Status: NEW ---    
Severity: normal CC: vriha
Priority: P3    
Version: 7.3   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:

Description _ tboudreau 2012-08-31 19:24:26 UTC
It is fairly common to see frameworks which want you to pass a very small javascript "object" as a parameter - witness node.js's http.request or node.js's mongodb driver.

It is annoying that reformat code breaks the formatting of small objects across lines - so this:

collection.update (query, data, {safe : true}, function (err, data) {
  ...
}

gets reformatted into much-less-readable:

collection.update (query, data, {
   safe : true
}, function (err, data) {
  ...
}

A simple heuristic which would get this right most of the time would be:
 - If the hash has 1-2 key/value pairs
 - If it is already on a single line
leave it alone,  otherwise reformat it.
Comment 1 Petr Pisl 2012-09-03 07:27:12 UTC
I think there could be an option for it. Some combobox with items 1 pair, 2 pars, 3 pairs, never, always.
Comment 2 _ tboudreau 2012-09-03 08:16:11 UTC
Okay, some sort of threshold number of items before a single-line hash is altered.

But what will the default be?
Comment 3 Petr Hejl 2012-09-03 08:19:26 UTC
(In reply to comment #2)
> Okay, some sort of threshold number of items before a single-line hash is
> altered.
> 
> But what will the default be?
Why "Object Properties: Never" is not enough?