From deac95e27448feb75eb51404634bd052c1af3667 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 1 Dec 2023 12:48:10 +0000 Subject: [PATCH] feat(prettier): print blank lines when printing array concisely (#1600) --- crates/oxc_prettier/src/format/array.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/oxc_prettier/src/format/array.rs b/crates/oxc_prettier/src/format/array.rs index 1a5e74dc7..4d677f51f 100644 --- a/crates/oxc_prettier/src/format/array.rs +++ b/crates/oxc_prettier/src/format/array.rs @@ -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!()); + } } } }