mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(prettier): keep EmptyStatement in Program (#1576)
This commit is contained in:
parent
3a00382d28
commit
3a4261ff5d
2 changed files with 10 additions and 8 deletions
|
|
@ -72,7 +72,12 @@ pub(super) fn print_block_body<'a>(
|
|||
}
|
||||
|
||||
if has_body {
|
||||
parts.extend(statement::print_statement_sequence(p, stmts, remove_last_statement_hardline));
|
||||
parts.extend(statement::print_statement_sequence(
|
||||
p,
|
||||
stmts,
|
||||
remove_last_statement_hardline,
|
||||
!is_root,
|
||||
));
|
||||
}
|
||||
|
||||
if is_root {
|
||||
|
|
|
|||
|
|
@ -13,16 +13,13 @@ pub(super) fn print_statement_sequence<'a>(
|
|||
p: &mut Prettier<'a>,
|
||||
stmts: &[Statement<'a>],
|
||||
remove_last_statement_hardline: bool,
|
||||
skip_empty_statement: bool,
|
||||
) -> Vec<'a, Doc<'a>> {
|
||||
let mut parts = p.vec();
|
||||
let mut len = stmts.len();
|
||||
let len = stmts.len();
|
||||
|
||||
for (i, stmt) in stmts.iter().enumerate() {
|
||||
if i < len - 1 && matches!(stmts[i + 1], Statement::EmptyStatement(_)) {
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
if matches!(stmt, Statement::EmptyStatement(_)) {
|
||||
if skip_empty_statement && matches!(stmt, Statement::EmptyStatement(_)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +40,7 @@ pub(super) fn print_statement_sequence<'a>(
|
|||
|
||||
parts.push(docs);
|
||||
|
||||
if i < len - 1 {
|
||||
if i < len - 1 && !matches!(stmts[i + 1], Statement::EmptyStatement(_)) {
|
||||
parts.extend(hardline!());
|
||||
|
||||
if p.is_next_line_empty(stmt.span()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue