fix excessive whitespace trimming resulting in innaccurate sourcemap line - fixes #151
This commit is contained in:
@@ -76,6 +76,8 @@ Buffer.prototype.newline = function (i, removeLast) {
|
||||
}
|
||||
|
||||
if (_.isNumber(i)) {
|
||||
if (this.endsWith(util.repeat(i, "\n"))) return;
|
||||
|
||||
var self = this;
|
||||
_.times(i, function () {
|
||||
self.newline(null, removeLast);
|
||||
@@ -86,7 +88,7 @@ Buffer.prototype.newline = function (i, removeLast) {
|
||||
if (removeLast && this.isLast("\n")) this.removeLast("\n");
|
||||
|
||||
this.removeLast(" ");
|
||||
this.buf = this.buf.replace(/\n(\s+)$/, "\n");
|
||||
this.buf = this.buf.replace(/\n +$/, "\n");
|
||||
this._push("\n");
|
||||
};
|
||||
|
||||
|
||||
@@ -115,8 +115,6 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
opts = opts || {};
|
||||
|
||||
var newline = function (leading) {
|
||||
var ignoreDuplicates = false;
|
||||
|
||||
if (!opts.statement && !n.isUserWhitespacable(node, parent)) {
|
||||
return;
|
||||
}
|
||||
@@ -139,7 +137,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
lines += needs(node, parent);
|
||||
}
|
||||
|
||||
self.newline(lines, ignoreDuplicates);
|
||||
self.newline(lines);
|
||||
};
|
||||
|
||||
if (this[node.type]) {
|
||||
|
||||
Reference in New Issue
Block a user