properly catch up to comments position - fixes #1384
This commit is contained in:
parent
4345f7945b
commit
16c86c25b7
@ -147,15 +147,17 @@ class CodeGenerator {
|
|||||||
return print;
|
return print;
|
||||||
}
|
}
|
||||||
|
|
||||||
print(node, parent, opts = {}) {
|
catchUp(node) {
|
||||||
if (!node) return;
|
|
||||||
|
|
||||||
// catch up to this nodes newline if we're behind
|
// catch up to this nodes newline if we're behind
|
||||||
if (node.loc && this.format.retainLines) {
|
if (node.loc && this.format.retainLines && this.buffer.buf) {
|
||||||
while (this.position.line < node.loc.start.line) {
|
while (this.position.line < node.loc.start.line) {
|
||||||
this._push("\n");
|
this._push("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print(node, parent, opts = {}) {
|
||||||
|
if (!node) return;
|
||||||
|
|
||||||
if (parent && parent._compact) {
|
if (parent && parent._compact) {
|
||||||
node._compact = true;
|
node._compact = true;
|
||||||
@ -205,6 +207,8 @@ class CodeGenerator {
|
|||||||
|
|
||||||
this.printLeadingComments(node, parent);
|
this.printLeadingComments(node, parent);
|
||||||
|
|
||||||
|
this.catchUp(node);
|
||||||
|
|
||||||
newline(true);
|
newline(true);
|
||||||
|
|
||||||
if (opts.before) opts.before();
|
if (opts.before) opts.before();
|
||||||
@ -336,6 +340,8 @@ class CodeGenerator {
|
|||||||
|
|
||||||
if (skip) return;
|
if (skip) return;
|
||||||
|
|
||||||
|
this.catchUp(comment);
|
||||||
|
|
||||||
// whitespace before
|
// whitespace before
|
||||||
this.newline(this.whitespace.getNewlinesBefore(comment));
|
this.newline(this.whitespace.getNewlinesBefore(comment));
|
||||||
|
|
||||||
@ -348,7 +354,6 @@ class CodeGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
if (comment.type === "Block" && this.format.indent.adjustMultilineComment) {
|
if (comment.type === "Block" && this.format.indent.adjustMultilineComment) {
|
||||||
var offset = comment.loc.start.column;
|
var offset = comment.loc.start.column;
|
||||||
if (offset) {
|
if (offset) {
|
||||||
@ -365,7 +370,6 @@ class CodeGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
this._push(val);
|
this._push(val);
|
||||||
|
|
||||||
// whitespace after
|
// whitespace after
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user