Skip to content

Commit

Permalink
fix another formatter bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jun 11, 2024
1 parent ec64642 commit de691d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ impl<'a> Formatter<'a> {
self.config.multiline_indent * depth
};
for (i, line) in lines.iter().enumerate() {
if i > 0 || prevent_compact || (!compact && allow_leading_space) {
if i > 0 || (prevent_compact && depth > 0) || (!compact && allow_leading_space) {
self.output.push('\n');
if !line.is_empty() {
for _ in 0..indent {
Expand All @@ -1188,10 +1188,11 @@ impl<'a> Formatter<'a> {
}
self.format_words(line, true, depth, true);
}
if !compact && !lines.iter().last().is_some_and(|line| line.is_empty()) {
self.output.push('\n');
}

if !compact {
if depth > 0 && !lines.iter().last().is_some_and(|line| line.is_empty()) {
self.output.push('\n');
}
for _ in 0..self.config.multiline_indent * depth.saturating_sub(1) {
self.output.push(' ');
}
Expand Down
3 changes: 2 additions & 1 deletion tests/loops.ua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ A ← ↯2_3_4⇡24
{{{8 9} 10} 11}]
[{{{12 13} 14} 15}
{{{16 17} 18} 19}
{{{20 21} 22} 23}]]
{{{20 21} 22} 23}]
]

# Reduce fills
⍤⟜≍: ¯∞ /↥ []
Expand Down
2 changes: 0 additions & 2 deletions tests/units.ua
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,7 @@ X ← |0
G ↚ +1
F ← G


# Constant vs Noadic function

F ← ⚂
G ← (⚂)

Expand Down

0 comments on commit de691d3

Please sign in to comment.