Correctly indent multiline comments when retainLines: true (#12260)
This commit is contained in:
parent
5b48f40a08
commit
87a30524f6
@ -612,7 +612,7 @@ export default class Printer {
|
|||||||
|
|
||||||
const indentSize = Math.max(
|
const indentSize = Math.max(
|
||||||
this._getIndent().length,
|
this._getIndent().length,
|
||||||
this._buf.getCurrentColumn(),
|
this.format.retainLines ? 0 : this._buf.getCurrentColumn(),
|
||||||
);
|
);
|
||||||
val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);
|
val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);
|
||||||
}
|
}
|
||||||
|
|||||||
15
packages/babel-generator/test/fixtures/comments/multi-comment-with-retainlines-option/input.js
vendored
Normal file
15
packages/babel-generator/test/fixtures/comments/multi-comment-with-retainlines-option/input.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
var foo = "this is a long string";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this is comment
|
||||||
|
*/
|
||||||
|
class Bar {}
|
||||||
|
|
||||||
|
{
|
||||||
|
const foo = "this is a really long line of text. this is a really long line of text.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example
|
||||||
|
*/
|
||||||
|
class A {}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"retainLines": true
|
||||||
|
}
|
||||||
15
packages/babel-generator/test/fixtures/comments/multi-comment-with-retainlines-option/output.js
vendored
Normal file
15
packages/babel-generator/test/fixtures/comments/multi-comment-with-retainlines-option/output.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
var foo = "this is a long string";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this is comment
|
||||||
|
*/
|
||||||
|
class Bar {}
|
||||||
|
|
||||||
|
{
|
||||||
|
const foo = "this is a really long line of text. this is a really long line of text.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example
|
||||||
|
*/
|
||||||
|
class A {}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user