Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit e70b3c9

Browse files
Fix printing of JSX in binary expressions. (#377)
The following snippet: ``` <Kbd keycap="Ctrl" /> + <Kbd keycap="Shift" /> + <Kbd keycap /> ``` would print in the non-sugared JSX form. Nested binary expressions should print JSX correctly. Fixes #373
1 parent 0b6a6e3 commit e70b3c9

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/res_parsetree_viewer.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,13 @@ let shouldInlineRhsBinaryExpr rhs = match rhs.pexp_desc with
453453

454454
let filterPrinteableAttributes attrs =
455455
List.filter (fun attr -> match attr with
456-
| ({Location.txt="bs" | "ns.ternary" | "ns.iflet"}, _) -> false
456+
| ({Location.txt="bs" | "ns.ternary" | "ns.iflet" | "JSX"}, _) -> false
457457
| _ -> true
458458
) attrs
459459

460460
let partitionPrinteableAttributes attrs =
461461
List.partition (fun attr -> match attr with
462-
| ({Location.txt="bs" | "ns.ternary" | "ns.iflet"}, _) -> false
462+
| ({Location.txt="bs" | "ns.ternary" | "ns.iflet" | "JSX"}, _) -> false
463463
| _ -> true
464464
) attrs
465465

tests/printer/expr/binary.res

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,15 @@ React.useEffect4(
388388
},
389389
(context.library, context.account, context.chainId, dispatch),
390390
)
391+
392+
@react.component
393+
let make = (~keycap) =>
394+
<Kbd keycap="Ctrl" /> +
395+
<Kbd keycap="Shift" /> +
396+
<Kbd keycap />
397+
398+
399+
<Kbd keycap="Cmd" /> +
400+
<Kbd keycap="Option" /> +
401+
<Kbd keycap="Shift" /> +
402+
<Kbd keycap />

tests/printer/expr/expected/binary.res.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,3 +511,8 @@ React.useEffect4(() => {
511511
| _ => None
512512
}
513513
}, (context.library, context.account, context.chainId, dispatch))
514+
515+
@react.component
516+
let make = (~keycap) => <Kbd keycap="Ctrl" /> + <Kbd keycap="Shift" /> + <Kbd keycap />
517+
518+
<Kbd keycap="Cmd" /> + <Kbd keycap="Option" /> + <Kbd keycap="Shift" /> + <Kbd keycap />

0 commit comments

Comments
 (0)