1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-07-31 12:37:45 +00:00

feat: expose all newlines to the engine

This commit is contained in:
Kevin Amado 2022-02-16 22:19:55 -05:00
parent a230667792
commit c7994c46b7
No known key found for this signature in database
GPG key ID: FFF341057F503148
6 changed files with 33 additions and 12 deletions

View file

@ -189,9 +189,7 @@ impl Children {
.filter(|c| *c == '\n')
.count();
if count > 1 {
callback(DrainCommentOrNewline::Newline(count));
}
callback(DrainCommentOrNewline::Newline(count));
self.move_next();
}
_ => {

View file

@ -84,8 +84,8 @@ pub fn rule(
steps.push_back(crate::builder::Step::Comment(text));
item_index += 1;
}
crate::children::DrainCommentOrNewline::Newline(_) => {
if item_index > 0 && item_index < items_count {
crate::children::DrainCommentOrNewline::Newline(newlines) => {
if newlines > 1 && item_index > 0 && item_index < items_count {
steps.push_back(crate::builder::Step::NewLine);
}
}

View file

@ -47,8 +47,8 @@ pub fn rule(
steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text));
}
crate::children::DrainCommentOrNewline::Newline(_) => {
if item_index > 0 && item_index < items_count {
crate::children::DrainCommentOrNewline::Newline(newlines) => {
if newlines > 1 && item_index > 0 && item_index < items_count {
steps.push_back(crate::builder::Step::NewLine);
}
}

View file

@ -44,8 +44,11 @@ pub fn rule(
steps.push_back(crate::builder::Step::Comment(text));
item_index += 1;
}
crate::children::DrainCommentOrNewline::Newline(_) => {
if item_index > 0 && item_index < items_count {
crate::children::DrainCommentOrNewline::Newline(newlines) => {
if newlines > 1
&& item_index > 0
&& item_index < items_count
{
steps.push_back(crate::builder::Step::NewLine);
}
}

View file

@ -42,8 +42,17 @@
* test
*/
[
a # comment
[ # 1
#2
a # 3
b
c # 4
#5
#6
d
#7
]
{

View file

@ -50,8 +50,19 @@
*/
[
# 1
#2
a
# comment
# 3
b
c
# 4
#5
#6
d
#7
]
{