Merge pull request #262 from josh/comment-before-newlines
Fix whitespace before comments
This commit is contained in:
commit
24f6dfa8e2
@ -68,7 +68,6 @@ Buffer.prototype.removeLast = function (cha) {
|
|||||||
Buffer.prototype.newline = function (i, removeLast) {
|
Buffer.prototype.newline = function (i, removeLast) {
|
||||||
if (!this.buf) return;
|
if (!this.buf) return;
|
||||||
if (this.format.compact) return;
|
if (this.format.compact) return;
|
||||||
if (this.endsWith("{\n")) return;
|
|
||||||
|
|
||||||
if (_.isBoolean(i)) {
|
if (_.isBoolean(i)) {
|
||||||
removeLast = i;
|
removeLast = i;
|
||||||
@ -76,6 +75,7 @@ Buffer.prototype.newline = function (i, removeLast) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_.isNumber(i)) {
|
if (_.isNumber(i)) {
|
||||||
|
if (this.endsWith("{\n")) i--;
|
||||||
if (this.endsWith(util.repeat(i, "\n"))) return;
|
if (this.endsWith(util.repeat(i, "\n"))) return;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|||||||
10
test/fixtures/generation/comments/2-space-multi-comment-with-space/actual.js
vendored
Normal file
10
test/fixtures/generation/comments/2-space-multi-comment-with-space/actual.js
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
function test() {
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this is comment
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var i = 20;
|
||||||
|
}
|
||||||
10
test/fixtures/generation/comments/2-space-multi-comment-with-space/expected.js
vendored
Normal file
10
test/fixtures/generation/comments/2-space-multi-comment-with-space/expected.js
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
function test() {
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this is comment
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var i = 20;
|
||||||
|
}
|
||||||
7
test/fixtures/generation/comments/comment-only-with-space/actual.js
vendored
Normal file
7
test/fixtures/generation/comments/comment-only-with-space/actual.js
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
// from #23
|
||||||
|
|
||||||
|
/**/
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
7
test/fixtures/generation/comments/comment-only-with-space/expected.js
vendored
Normal file
7
test/fixtures/generation/comments/comment-only-with-space/expected.js
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
// from #23
|
||||||
|
|
||||||
|
/**/
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
Loading…
x
Reference in New Issue
Block a user