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 - Reformatting should not split small hashes
Summary: Reformatting should not split small hashes
Status: NEW
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3
Hardware: PC Linux
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-31 19:24 UTC by _ tboudreau
Modified: 2015-09-30 12:48 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?