fix current_col and force a newline every 32K (support options.max_line_len)
This commit is contained in:
@@ -51,6 +51,7 @@ function OutputStream(options) {
|
|||||||
ascii_only : false,
|
ascii_only : false,
|
||||||
inline_script : false,
|
inline_script : false,
|
||||||
width : 80,
|
width : 80,
|
||||||
|
max_line_len : 32000,
|
||||||
ie_proof : true,
|
ie_proof : true,
|
||||||
beautify : true
|
beautify : true
|
||||||
});
|
});
|
||||||
@@ -119,6 +120,11 @@ function OutputStream(options) {
|
|||||||
return last.charAt(last.length - 1);
|
return last.charAt(last.length - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function maybe_newline() {
|
||||||
|
if (options.max_line_len && current_col > options.max_line_len)
|
||||||
|
print("\n");
|
||||||
|
};
|
||||||
|
|
||||||
function print(str) {
|
function print(str) {
|
||||||
str = String(str);
|
str = String(str);
|
||||||
var ch = str.charAt(0);
|
var ch = str.charAt(0);
|
||||||
@@ -131,6 +137,7 @@ function OutputStream(options) {
|
|||||||
might_need_space = false;
|
might_need_space = false;
|
||||||
}
|
}
|
||||||
might_need_semicolon = false;
|
might_need_semicolon = false;
|
||||||
|
maybe_newline();
|
||||||
}
|
}
|
||||||
if (might_need_space) {
|
if (might_need_space) {
|
||||||
if ((is_identifier_char(last_char())
|
if ((is_identifier_char(last_char())
|
||||||
@@ -143,13 +150,14 @@ function OutputStream(options) {
|
|||||||
current_pos++;
|
current_pos++;
|
||||||
}
|
}
|
||||||
might_need_space = false;
|
might_need_space = false;
|
||||||
|
maybe_newline();
|
||||||
}
|
}
|
||||||
var a = str.split(/\r?\n/), n = a.length;
|
var a = str.split(/\r?\n/), n = a.length;
|
||||||
current_line += n;
|
current_line += n;
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
current_col = a[n - 1].length;
|
|
||||||
} else {
|
|
||||||
current_col += a[n - 1].length;
|
current_col += a[n - 1].length;
|
||||||
|
} else {
|
||||||
|
current_col = a[n - 1].length;
|
||||||
}
|
}
|
||||||
current_pos += str.length;
|
current_pos += str.length;
|
||||||
last = str;
|
last = str;
|
||||||
|
|||||||
Reference in New Issue
Block a user