Skip to content

Commit 1ceb9d5

Browse files
committed
Fix JSON unicode string
String.escaped doesn't support unicode... so we're gonna use Json.escape instead. Fixes #114
1 parent 0d50510 commit 1ceb9d5

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

analysis/.depend

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ src/Process_406.cmx : src/SharedTypes.cmx src/Shared.cmx \
3636
src/ProcessExtra.cmx src/ProcessCmt.cmx src/PrintType.cmx \
3737
src/Process_406.cmi
3838
src/Process_406.cmi : src/Uri2.cmx src/SharedTypes.cmx
39-
src/Protocol.cmx :
39+
src/Protocol.cmx : src/vendor/Json.cmx
4040
src/Query.cmx : src/SharedTypes.cmx src/Log.cmx src/Infix.cmx
4141
src/References.cmx : src/Utils.cmx src/Uri2.cmx src/SharedTypes.cmx \
4242
src/Query.cmx src/Log.cmx src/Infix.cmx

analysis/src/Protocol.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let stringifyRange r =
4242

4343
let stringifyMarkupContent (m: markupContent) =
4444
Printf.sprintf {|{"kind": "%s", "value": "%s"}|}
45-
m.kind (String.escaped m.value)
45+
m.kind (Json.escape m.value)
4646

4747
let stringifyCompletionItem c =
4848
Printf.sprintf {|{
@@ -52,19 +52,19 @@ let stringifyCompletionItem c =
5252
"detail": "%s",
5353
"documentation": %s
5454
}|}
55-
(String.escaped c.label)
55+
(Json.escape c.label)
5656
c.kind
5757
(c.tags |> List.map string_of_int |> array)
58-
(String.escaped c.detail)
58+
(Json.escape c.detail)
5959
(stringifyMarkupContent c.documentation)
6060

6161
let stringifyHover h =
6262
Printf.sprintf {|{"contents": "%s"}|}
63-
(String.escaped h.contents)
63+
(Json.escape h.contents)
6464

6565
let stringifyLocation h =
6666
Printf.sprintf {|{"uri": "%s", "range": %s}|}
67-
(String.escaped h.uri)
67+
(Json.escape h.uri)
6868
(stringifyRange h.range)
6969

7070
let null = "null"

analysis/tests/src/expected/Complete.res.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ Complete tests/src/Complete.res 23:2
382382
"kind": 12,
383383
"tags": [],
384384
"detail": "t => t",
385-
"documentation": {"kind": "markdown", "value": "`toUpperCase str` converts `str` to upper case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can expand the number of letters in the result; for example the German `\195\159` capitalizes to two `S`es in a row.\n\n```ml\ntoUpperCase \"abc\" = \"ABC\";;\ntoUpperCase {js|Stra\195\159e|js} = {js|STRASSE|js};;\ntoLowerCase {js|\207\128\207\130|js} = {js|\206\160\206\163|js};;\n```\n\n\n\njs_string2.ml:601"}
385+
"documentation": {"kind": "markdown", "value": "`toUpperCase str` converts `str` to upper case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can expand the number of letters in the result; for example the German `ß` capitalizes to two `S`es in a row.\n\n```ml\ntoUpperCase \"abc\" = \"ABC\";;\ntoUpperCase {js|Straße|js} = {js|STRASSE|js};;\ntoLowerCase {js|πς|js} = {js|ΠΣ|js};;\n```\n\n\n\njs_string2.ml:601"}
386386
}]
387387

388388
Complete tests/src/Complete.res 27:2

0 commit comments

Comments
 (0)