Fix broken return-statements for preserve_line and extend with no_empty_line
This commit is contained in:
parent
f101d6429b
commit
86df7d95ff
|
|
@ -61,6 +61,7 @@ function OutputStream(options) {
|
||||||
semicolons : true,
|
semicolons : true,
|
||||||
comments : false,
|
comments : false,
|
||||||
preserve_line : false,
|
preserve_line : false,
|
||||||
|
no_empty_line : false,
|
||||||
screw_ie8 : false,
|
screw_ie8 : false,
|
||||||
preamble : null,
|
preamble : null,
|
||||||
}, true);
|
}, true);
|
||||||
|
|
@ -69,6 +70,7 @@ function OutputStream(options) {
|
||||||
var current_col = 0;
|
var current_col = 0;
|
||||||
var current_line = 1;
|
var current_line = 1;
|
||||||
var current_pos = 0;
|
var current_pos = 0;
|
||||||
|
var current_line_offset = 0;
|
||||||
var OUTPUT = "";
|
var OUTPUT = "";
|
||||||
|
|
||||||
function to_ascii(str, identifier) {
|
function to_ascii(str, identifier) {
|
||||||
|
|
@ -150,7 +152,9 @@ function OutputStream(options) {
|
||||||
OUTPUT += ";";
|
OUTPUT += ";";
|
||||||
current_col++;
|
current_col++;
|
||||||
current_pos++;
|
current_pos++;
|
||||||
} else {
|
} else if (!options.preserve_line ||
|
||||||
|
OUTPUT.substr(-6) !== "return")
|
||||||
|
{
|
||||||
OUTPUT += "\n";
|
OUTPUT += "\n";
|
||||||
current_pos++;
|
current_pos++;
|
||||||
current_line++;
|
current_line++;
|
||||||
|
|
@ -165,12 +169,20 @@ function OutputStream(options) {
|
||||||
|
|
||||||
if (!options.beautify && options.preserve_line && stack[stack.length - 1]) {
|
if (!options.beautify && options.preserve_line && stack[stack.length - 1]) {
|
||||||
var target_line = stack[stack.length - 1].start.line;
|
var target_line = stack[stack.length - 1].start.line;
|
||||||
while (current_line < target_line) {
|
while (current_line + current_line_offset < target_line) {
|
||||||
|
if (OUTPUT.substr(-6) === "return")
|
||||||
|
break;
|
||||||
|
|
||||||
OUTPUT += "\n";
|
OUTPUT += "\n";
|
||||||
current_pos++;
|
current_pos++;
|
||||||
current_line++;
|
current_line++;
|
||||||
current_col = 0;
|
current_col = 0;
|
||||||
might_need_space = false;
|
might_need_space = false;
|
||||||
|
|
||||||
|
if (options.no_empty_line) {
|
||||||
|
current_line_offset = target_line - current_line;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user