diff options
author | Mihai Bazon <mihai.bazon@gmail.com> | 2015-07-30 17:25:13 +0300 |
---|---|---|
committer | Mihai Bazon <mihai.bazon@gmail.com> | 2015-07-30 17:25:13 +0300 |
commit | ab15d676d71653706386c24c5ec9046ece6b6eaf (patch) | |
tree | 7197dfe5963167c1e31a99ca7355145baeb0cfbc /lib | |
parent | 3afad58a93903257e8e3cb0a7b90ff79212f46bd (diff) | |
parent | 66761d7ecfade3c81c09f9b77afc5b71b3b59f9e (diff) | |
download | tracifyjs-ab15d676d71653706386c24c5ec9046ece6b6eaf.tar.gz tracifyjs-ab15d676d71653706386c24c5ec9046ece6b6eaf.zip |
Merge pull request #757 from rvanvelzen/semicolon-fix
Fix semicolon printing when restricting max line length
Diffstat (limited to 'lib')
-rw-r--r-- | lib/output.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/output.js b/lib/output.js index 1d67b1b9..396c6a29 100644 --- a/lib/output.js +++ b/lib/output.js @@ -161,6 +161,8 @@ function OutputStream(options) { str = String(str); var ch = str.charAt(0); if (might_need_semicolon) { + might_need_semicolon = false; + if ((!ch || ";}".indexOf(ch) < 0) && !/[;]$/.test(last)) { if (options.semicolons || requireSemicolonChars(ch)) { OUTPUT += ";"; @@ -171,11 +173,17 @@ function OutputStream(options) { current_pos++; current_line++; current_col = 0; + + if (/^\s+$/.test(str)) { + // reset the semicolon flag, since we didn't print one + // now and might still have to later + might_need_semicolon = true; + } } + if (!options.beautify) might_need_space = false; } - might_need_semicolon = false; } if (!options.beautify && options.preserve_line && stack[stack.length - 1]) { |