Skip to content

Commit 6f7e80c

Browse files
committed
fix: Increase the indentation when inlining the first argument
1 parent 3b41c51 commit 6f7e80c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/formatter.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ impl<'a> Formatter<'a> {
302302
.max_inline_arguments
303303
.is_none_or(|limit| limit < self.indentation.span())
304304
{
305+
// We inlined something to the top level let's increase the indentation now
306+
if let Some((t, s)) = self.indentation.previous_top_level_reserved() {
307+
if !s.newline_after {
308+
self.indentation.increase_top_level(s.clone());
309+
}
310+
}
311+
305312
self.add_new_line(query);
306313
} else {
307314
self.trim_spaces_end(query);

src/indentation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ impl<'a> Indentation<'a> {
7676
folded = kind == Some(IndentType::FoldedBlock);
7777
if kind != Some(IndentType::Top) {
7878
break;
79+
} else {
80+
self.top_level_span.pop();
7981
}
8082
}
8183
folded

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2556,7 +2556,7 @@ from
25562556
SELECT true
25572557
FROM bar
25582558
WHERE bar.foo = $99
2559-
AND bar.foo > $100
2559+
AND bar.foo > $100
25602560
),
25612561
c = CASE WHEN $6 THEN NULL ELSE COALESCE($7, c) END,
25622562
d = CASE

0 commit comments

Comments
 (0)