Repository: dprint/dprint-plugin-typescript (rust)

Issue:
useBraces=whenNotSingleLine adds braces when conditional spans multiple lines
**Describe the bug**

dprint-plugin-typescript version: 0.73.0

```
{
  "indentWidth": 4,
  "useBraces": "whenNotSingleLine",
  "singleBodyPosition": "maintain"
}
```

**Input Code**

```ts
if (someFunction({
    xyz: 1234
})) return;
```

**Expected Output**

```ts
if (
    someFunction({
        xyz: 1234,
    })
) return;
```

**Actual Output**

```ts
if (
    someFunction({
        xyz: 1234,
    })
) { return; }
```

Setting `"singleBodyPosition": "maintain"` fixes this. Probably similar in vein to #359.


Pull request description:
fix: useBraces: whenNotSingleLine should not add braces when header end ln == statement end ln
Closes #416

Patch:
diff --git a/src/generation/generate.rs b/src/generation/generate.rs
index a582475..a34e0fe 100644
--- a/src/generation/generate.rs
+++ b/src/generation/generate.rs
@@ -8034,7 +8034,7 @@ fn gen_conditional_brace_body<'a>(opts: GenConditionalBraceBodyOptions<'a>, cont
             if force_braces {
               Some(true)
             } else {
-              let is_multiple_lines = condition_helpers::is_multiple_lines(condition_context, start_header_ln.unwrap_or(start_lc.line), end_ln)?;
+              let is_multiple_lines = condition_helpers::is_multiple_lines(condition_context, end_header_ln.unwrap_or(start_lc.line), end_ln)?;
               Some(is_multiple_lines)
             }
           }


Test patch:
diff --git a/tests/specs/issues/issue0416.txt b/tests/specs/issues/issue0416.txt
new file mode 100644
index 0000000..ada0af9
--- /dev/null
+++ b/tests/specs/issues/issue0416.txt
@@ -0,0 +1,24 @@
+~~ indentWidth: 4, useBraces: whenNotSingleLine, singleBodyPosition: maintain ~~
+== should not add braces ==
+if (someFunction({
+    xyz: 1234
+})) return;
+if (someFunction({
+    xyz: 1234
+})) {
+    return;
+}
+
+[expect]
+if (
+    someFunction({
+        xyz: 1234,
+    })
+) return;
+if (
+    someFunction({
+        xyz: 1234,
+    })
+) {
+    return;
+}