Skip to content

Commit a2af63c

Browse files
committed
Fix heuristic for detecting "uncurried": true in bsconfig.
After #6080
1 parent 7b0e7e5 commit a2af63c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

res_syntax/src/res_multi_printer.ml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let defaultPrintWidth = 100
22

33
(* Determine if the file is in uncurried mode by looking for
4-
the fist ancestor .bsconfig and see if it contains "uncurried": "true" *)
4+
the fist ancestor .bsconfig and see if it contains "uncurried": true *)
55
let getUncurriedFromBsconfig ~filename =
66
let rec findBsconfig ~dir =
77
let bsconfig = Filename.concat dir "bsconfig.json" in
@@ -41,9 +41,19 @@ let getUncurriedFromBsconfig ~filename =
4141
let uncurried =
4242
lines
4343
|> List.exists (fun line ->
44-
let words = line |> String.split_on_char '\"' in
45-
words |> List.exists (fun word -> word = "uncurried")
46-
&& words |> List.exists (fun word -> word = "true"))
44+
let uncurried = ref false in
45+
let true_ = ref false in
46+
let words = line |> String.split_on_char ' ' in
47+
words
48+
|> List.iter (fun word ->
49+
match word with
50+
| "\"uncurried\"" | "\"uncurried\":" -> uncurried := true
51+
| "\"uncurried\":true" | "\"uncurried\":true," ->
52+
uncurried := true;
53+
true_ := true
54+
| "true" | ":true" | "true," | ":true," -> true_ := true
55+
| _ -> ());
56+
!uncurried && !true_)
4757
in
4858
if uncurried then Config.uncurried := Uncurried
4959

0 commit comments

Comments
 (0)