Skip to content

Commit ce2425c

Browse files
authored
fix: useBraces: whenNotSingleLine should not add braces when header end ln == statement end ln (#419)
Closes #416
1 parent fadad2e commit ce2425c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/generation/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8034,7 +8034,7 @@ fn gen_conditional_brace_body<'a>(opts: GenConditionalBraceBodyOptions<'a>, cont
80348034
if force_braces {
80358035
Some(true)
80368036
} else {
8037-
let is_multiple_lines = condition_helpers::is_multiple_lines(condition_context, start_header_ln.unwrap_or(start_lc.line), end_ln)?;
8037+
let is_multiple_lines = condition_helpers::is_multiple_lines(condition_context, end_header_ln.unwrap_or(start_lc.line), end_ln)?;
80388038
Some(is_multiple_lines)
80398039
}
80408040
}

tests/specs/issues/issue0416.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
~~ indentWidth: 4, useBraces: whenNotSingleLine, singleBodyPosition: maintain ~~
2+
== should not add braces ==
3+
if (someFunction({
4+
xyz: 1234
5+
})) return;
6+
if (someFunction({
7+
xyz: 1234
8+
})) {
9+
return;
10+
}
11+
12+
[expect]
13+
if (
14+
someFunction({
15+
xyz: 1234,
16+
})
17+
) return;
18+
if (
19+
someFunction({
20+
xyz: 1234,
21+
})
22+
) {
23+
return;
24+
}

0 commit comments

Comments
 (0)