feat(prettier): print blank lines when printing array concisely (#1600)

This commit is contained in:
Cameron 2023-12-01 12:48:10 +00:00 committed by GitHub
parent f4f392e19f
commit deac95e274
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,12 +1,12 @@
use oxc_ast::ast::*;
use oxc_span::Span;
use oxc_span::{GetSpan, Span};
use oxc_syntax::operator::UnaryOperator;
use crate::{
array,
comments::DanglingCommentsPrintOptions,
doc::{Doc, DocBuilder, Fill, Group},
group, if_break, indent, line, softline, ss, Prettier,
group, hardline, if_break, indent, line, softline, ss, Prettier,
};
use super::Format;
@ -212,7 +212,14 @@ where
parts.push(part);
if !is_last {
parts.push(line!());
if p.is_next_line_empty_after_index(element.span().end) {
let mut space_parts = p.vec();
space_parts.extend(hardline!());
space_parts.extend(hardline!());
parts.push(Doc::Array(space_parts));
} else {
parts.push(line!());
}
}
}
}