This commit is contained in:
Andreas Svensson 2015-08-27 10:10:26 +00:00
commit 8a4e6d8c38

View File

@ -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,
quote_style : 0 quote_style : 0
@ -70,6 +71,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) {
@ -168,7 +170,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++;
@ -188,12 +192,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;
}
} }
} }