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

Commit 5576952

Browse files
committed
Restore wilBreak functionality.
1 parent 5259445 commit 5576952

File tree

6 files changed

+41
-26
lines changed

6 files changed

+41
-26
lines changed

src/res_doc.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ let rec willBreak doc =
115115
| LineBreak (Hard | Literal) | BreakParent | Group {shouldBreak = true} ->
116116
true
117117
| Group {doc} | Indent doc -> willBreak doc
118-
| CustomLayout {groups = _lazyDoc :: _} -> false
118+
| CustomLayout {groups = lazyDoc :: _} -> willBreak (Lazy.force lazyDoc)
119119
| Concat docs -> List.exists willBreak docs
120120
| IfBreaks {yes; no} -> willBreak yes || willBreak no
121121
| _ -> false

tests/conversion/reason/expected/bracedJsx.res.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ let make = () => {
112112
className=Styles.terminal
113113
onClick={event => (event->ReactEvent.Mouse.target)["querySelector"]("input")["focus"]()}
114114
ref={containerRef->ReactDOMRe.Ref.domRef}>
115-
{state.history->Array.mapWithIndex((index, item) =>
115+
{state.history
116+
->Array.mapWithIndex((index, item) =>
116117
<div key={j`$index`} className=Styles.line>
117118
{ReasonReact.string(
118119
switch item {
@@ -121,7 +122,8 @@ let make = () => {
121122
},
122123
)}
123124
</div>
124-
)->ReasonReact.array}
125+
)
126+
->ReasonReact.array}
125127
<div>
126128
{userPrefix->ReasonReact.string}
127129
{<input

tests/conversion/reason/expected/fastPipe.res.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ let x = @attr ((@attr2 a)->f(b)->c(d))
1515
Route.urlToRoute(url)->ChangeView->self.send
1616

1717
let aggregateTotal = (forecast, ~audienceType) =>
18-
Js.Nullable.toOption(forecast["audiences"])->Option.flatMap(item =>
19-
Js.Dict.get(item, audienceType)
20-
)->Option.map(item => {
18+
Js.Nullable.toOption(forecast["audiences"])
19+
->Option.flatMap(item => Js.Dict.get(item, audienceType))
20+
->Option.map(item => {
2121
pages: item["reach"]["pages"],
2222
views: item["reach"]["views"],
2323
sample: item["reach"]["sample"],

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,9 @@ foo :=
481481
) |> Array.of_list |> ReasonReact.array} </div>
482482

483483
let aggregateTotal = (forecast, ~audienceType) =>
484-
Js.Nullable.toOption(forecast["audiences"])->Option.flatMap(item =>
485-
Js.Dict.get(item, audienceType)
486-
)->Option.map(item => {
484+
Js.Nullable.toOption(forecast["audiences"])
485+
->Option.flatMap(item => Js.Dict.get(item, audienceType))
486+
->Option.map(item => {
487487
pages: item["reach"]["pages"],
488488
views: item["reach"]["views"],
489489
sample: item["reach"]["sample"],
@@ -492,13 +492,13 @@ let aggregateTotal = (forecast, ~audienceType) =>
492492
React.useEffect4(() => {
493493
switch (context.library, context.account) {
494494
| (Some(library), Some(account)) =>
495-
library.getBalance(. account)->Promise.Js.catch(_ => {Promise.resolved(None)})->Promise.get(
496-
newBalance => {
497-
dispatch(LoadAddress(account, newBalance->Belt.Option.flatMap(balance =>
498-
Eth.make(balance.toString(.))
499-
)))
500-
},
501-
)
495+
library.getBalance(. account)
496+
->Promise.Js.catch(_ => {Promise.resolved(None)})
497+
->Promise.get(newBalance => {
498+
dispatch(LoadAddress(account, newBalance->Belt.Option.flatMap(balance =>
499+
Eth.make(balance.toString(.))
500+
)))
501+
})
502502

503503
None
504504
| _ => None

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,17 @@ foo(list => list())
179179
foo(\"switch" => \"switch"())
180180

181181
// the [] of the array should break
182-
[fn(x => {
182+
[
183+
fn(x => {
183184
let _ = x
184-
}), fn(y => {
185+
}),
186+
fn(y => {
185187
let _ = y
186-
}), fn(z => {
188+
}),
189+
fn(z => {
187190
let _ = z
188-
})]
191+
}),
192+
]
189193

190194
// similar, the jsx tree should be broken over multiple lines
191195
let f = () => {
@@ -196,9 +200,13 @@ let f = () => {
196200
| Done(Error(_)) => "Error"->React.string
197201
| Done(Ok(users)) =>
198202
<>
199-
<ul> {users->Array.map(user => {
203+
<ul>
204+
{users
205+
->Array.map(user => {
200206
<li key=user.id> {user.username->React.string} </li>
201-
})->React.array} </ul>
207+
})
208+
->React.array}
209+
</ul>
202210
{reloadableUser.last->AsyncData.isLoading ? "Loading next page"->React.string : React.null}
203211
<button onClick={_ => setPage(x => x + 1)}> {"Load next page"->React.string} </button>
204212
</>
@@ -217,9 +225,10 @@ myPromise->Js.Promise.then_(value => {
217225
Js.Promise.resolve(-2)
218226
}, _)
219227

220-
let decoratorTags = items->Js.Array2.filter(items => {
221-
items.category === Decorators
222-
})->Belt.Array.map(item => {
228+
let decoratorTags =
229+
items
230+
->Js.Array2.filter(items => {items.category === Decorators})
231+
->Belt.Array.map(item => {
223232
<span className="mr-2" key=item.name>
224233
<Tag text={item.name} />
225234
</span>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ let f = x => {
4747
->Option.flatMap(Js.Json.decodeString)
4848
->Option.map(Js.Date.fromString)
4949

50-
let b = x->Js.Dict.get("wm-property")->Option.flatMap(Js.Json.decodeString)->Option.flatMap(x =>
50+
let b =
51+
x
52+
->Js.Dict.get("wm-property")
53+
->Option.flatMap(Js.Json.decodeString)
54+
->Option.flatMap(x =>
5155
switch x {
5256
| "like-of" => Some(#like)
5357
| "repost-of" => Some(#repost)

0 commit comments

Comments
 (0)