mirror of
https://github.com/RGBCube/alejandra
synced 2025-08-01 04:57:44 +00:00
feat: expose all newlines to the engine
This commit is contained in:
parent
a230667792
commit
c7994c46b7
6 changed files with 33 additions and 12 deletions
|
@ -189,9 +189,7 @@ impl Children {
|
||||||
.filter(|c| *c == '\n')
|
.filter(|c| *c == '\n')
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
if count > 1 {
|
callback(DrainCommentOrNewline::Newline(count));
|
||||||
callback(DrainCommentOrNewline::Newline(count));
|
|
||||||
}
|
|
||||||
self.move_next();
|
self.move_next();
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -84,8 +84,8 @@ pub fn rule(
|
||||||
steps.push_back(crate::builder::Step::Comment(text));
|
steps.push_back(crate::builder::Step::Comment(text));
|
||||||
item_index += 1;
|
item_index += 1;
|
||||||
}
|
}
|
||||||
crate::children::DrainCommentOrNewline::Newline(_) => {
|
crate::children::DrainCommentOrNewline::Newline(newlines) => {
|
||||||
if item_index > 0 && item_index < items_count {
|
if newlines > 1 && item_index > 0 && item_index < items_count {
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ pub fn rule(
|
||||||
steps.push_back(crate::builder::Step::Pad);
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
steps.push_back(crate::builder::Step::Comment(text));
|
steps.push_back(crate::builder::Step::Comment(text));
|
||||||
}
|
}
|
||||||
crate::children::DrainCommentOrNewline::Newline(_) => {
|
crate::children::DrainCommentOrNewline::Newline(newlines) => {
|
||||||
if item_index > 0 && item_index < items_count {
|
if newlines > 1 && item_index > 0 && item_index < items_count {
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,11 @@ pub fn rule(
|
||||||
steps.push_back(crate::builder::Step::Comment(text));
|
steps.push_back(crate::builder::Step::Comment(text));
|
||||||
item_index += 1;
|
item_index += 1;
|
||||||
}
|
}
|
||||||
crate::children::DrainCommentOrNewline::Newline(_) => {
|
crate::children::DrainCommentOrNewline::Newline(newlines) => {
|
||||||
if item_index > 0 && item_index < items_count {
|
if newlines > 1
|
||||||
|
&& item_index > 0
|
||||||
|
&& item_index < items_count
|
||||||
|
{
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,17 @@
|
||||||
* test
|
* test
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[
|
[ # 1
|
||||||
a # comment
|
#2
|
||||||
|
a # 3
|
||||||
|
b
|
||||||
|
c # 4
|
||||||
|
#5
|
||||||
|
|
||||||
|
#6
|
||||||
|
|
||||||
|
d
|
||||||
|
#7
|
||||||
]
|
]
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,8 +50,19 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[
|
[
|
||||||
|
# 1
|
||||||
|
#2
|
||||||
a
|
a
|
||||||
# comment
|
# 3
|
||||||
|
b
|
||||||
|
c
|
||||||
|
# 4
|
||||||
|
#5
|
||||||
|
|
||||||
|
#6
|
||||||
|
|
||||||
|
d
|
||||||
|
#7
|
||||||
]
|
]
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue