einars/js-beautify — Issue #96: Keeping New lines 
Author: wisec
Created: 2012-02-14 15:01:55+00:00
State: open

Would it be possible to keep original newlines by simply adding:
preserve_max_newlines:1
to beautify options?

By modifying n_newlines condition it's "probably" easy to preserve the nl.
What do you think?

--- beautify.js	2012-02-14 15:37:23.000000000 +0100
+++ beautify.js	2012-02-14 15:55:37.000000000 +0100
@@ -345,7 +345,7 @@ function js_beautify(js_source_text, opt
}

if (opt_preserve_newlines) {
- if (n_newlines > 1) {
+ if (n_newlines > 0) {
for (i = 0; i < n_newlines; i += 1) {
print_newline(i === 0);
just_added_newline = true;

--
Of cours if the patch is wrong i'd like to understand why.

Thanks