Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/lib/src/utils/reflow/reindent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ fn crawl_indent_points(
initial_indent_balance: indent_balance,
last_line_break_idx: cached_point.last_line_break_idx,
is_line_break: true,
untaken_indents: take(&mut untaken_indents),
untaken_indents: untaken_indents.clone(),
});
// Before zeroing, crystallise any effect on overall
// balances.
Expand Down
53 changes: 53 additions & 0 deletions crates/lib/test/fixtures/rules/std_rule_cases/LT02-indent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2174,3 +2174,56 @@ test_pass_implicit_where:
configs:
indentation:
allow_implicit_indents: true

test_pass_comment_in_bracketed_expression:
# Github Bug #1967
# A comment inside parentheses should not cause extra indentation.
pass_str: |
SELECT
col1,
col2
FROM (
SELECT
col1,
(
-- This comment should not break indentation.
file_type ILIKE '%tif%' -- inline comment
) AS col2,
another_col
FROM my_table
) a
GROUP BY col1, col2

test_fix_comment_in_bracketed_expression:
# Github Bug #1967
# A comment inside parentheses should not cause extra indentation.
fail_str: |
SELECT
col1,
col2
FROM (
SELECT
col1,
(
-- This comment should not break indentation.
file_type ILIKE '%tif%' -- inline comment
) AS col2,
another_col
FROM my_table
) a
GROUP BY col1, col2
fix_str: |
SELECT
col1,
col2
FROM (
SELECT
col1,
(
-- This comment should not break indentation.
file_type ILIKE '%tif%' -- inline comment
) AS col2,
another_col
FROM my_table
) a
GROUP BY col1, col2
Loading