Skip to content

Commit

Permalink
refactor: fix against newer versions of dune (ocaml#1200)
Browse files Browse the repository at this point in the history
removes the incomplete pattern match warning on the progress

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Oct 16, 2023
1 parent 672ca1b commit 841fe5c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ocaml-lsp-server/src/progress.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let build_progress t (progress : Drpc.Progress.t) =
| Failed -> end_build t ~message:"Build failed"
| Interrupted -> end_build t ~message:"Build interrupted"
| Waiting -> end_build t ~message:"Waiting for changes"
| In_progress { complete; remaining } ->
| In_progress progress ->
let* token =
match token with
| Some token -> Fiber.return token
Expand All @@ -75,19 +75,23 @@ let build_progress t (progress : Drpc.Progress.t) =
build. *)
start_build t
in
let total = complete + remaining in
let total = progress.complete + progress.remaining in
(* The percentage is useless as it isn't monotinically increasing as
the spec requires, but it's the best we can do. *)
let percentage =
let fraction = float_of_int complete /. float_of_int total in
let fraction =
float_of_int progress.complete /. float_of_int total
in
int_of_float (fraction *. 100.)
in
report_progress
(ProgressParams.create
~token
~value:
(Progress.Report
(let message = sprintf "Building [%d/%d]" complete total in
(let message =
sprintf "Building [%d/%d]" progress.complete total
in
WorkDoneProgressReport.create ~percentage ~message ())))))

let should_report_build_progress = function
Expand Down

0 comments on commit 841fe5c

Please sign in to comment.