fix excessive whitespace trimming resulting in innaccurate sourcemap line - fixes #151

This commit is contained in:
Sebastian McKenzie
2014-11-13 12:25:11 +11:00
parent 0c7e0b65b9
commit 9c1b60e451
29 changed files with 12 additions and 39 deletions

View File

@@ -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");
};