Skip to content

Commit 62f8c4e

Browse files
authored
fix(lsp): make write take list of strings (#1085)
So that we don't have to assume that writes aren't interleaved Signed-off-by: Rudi Grinberg <[email protected]>
1 parent e309486 commit 62f8c4e

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

lsp-fiber/src/fiber_io.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ module Io =
2828
| Ok s -> Some s
2929
| Error (`Partial_eof _) -> None
3030

31-
let write oc s =
31+
let write oc strings =
3232
Fiber.of_thunk (fun () ->
33-
Lio.Writer.add_string oc s;
33+
List.iter strings ~f:(Lio.Writer.add_string oc);
3434
Fiber.return ())
3535
end)
3636

lsp/src/io.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end) (Chan : sig
5050

5151
val read_exactly : input -> int -> string option Io.t
5252

53-
val write : output -> string -> unit Io.t
53+
val write : output -> string list -> unit Io.t
5454
end) =
5555
struct
5656
open Io.O
@@ -112,6 +112,5 @@ struct
112112
let data = Json.to_string json in
113113
let content_length = String.length data in
114114
let header = Header.create ~content_length () in
115-
let* () = Chan.write chan (Header.to_string header) in
116-
Chan.write chan data
115+
Chan.write chan [ Header.to_string header; data ]
117116
end

lsp/src/io.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ end) (Chan : sig
2323

2424
val read_exactly : input -> int -> string option Io.t
2525

26-
val write : output -> string -> unit Io.t
26+
val write : output -> string list -> unit Io.t
2727
end) : sig
2828
val read : Chan.input -> Jsonrpc.Packet.t option Io.t
2929

0 commit comments

Comments
 (0)