fix pointless newlines after left braces
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user