fix pointless newlines after left braces

This commit is contained in:
Sebastian McKenzie
2014-11-07 20:47:09 +11:00
parent 159f5217e3
commit 35b7b140da

View File

@@ -56,6 +56,7 @@ CodeGenerator.prototype.mark = function (node, type) {
CodeGenerator.prototype.newline = function (i, removeLast) {
if (!this.buf) return;
if (this.endsWith("{\n")) return;
if (_.isBoolean(i)) {
removeLast = i;
@@ -159,6 +160,10 @@ CodeGenerator.prototype._push = function (str) {
this.buf += str;
};
CodeGenerator.prototype.endsWith = function (str) {
return this.buf.slice(-str.length) === str;
};
CodeGenerator.prototype.isLast = function (cha, trimRight) {
var buf = this.buf;
if (trimRight) buf = buf.trimRight();
@@ -189,7 +194,6 @@ CodeGenerator.prototype.generate = function () {
this.print(ast);
this.buf = this.buf.trimRight();
this.buf = this.buf.replace(/\{\n\n/g, "{\n");
var map = this.map;
if (map) map = map.toJSON();