Skip to content

Commit

Permalink
Keep around the latest valid program and jump table
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-botbol committed Oct 29, 2024
1 parent 6487895 commit 71d7132
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion server/src/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class catala_lsp_server =
val mutable prelude = []

method private process_and_update_file ?contents uri =
let f = State.process_document ?contents uri in
let previous_file = Hashtbl.find_opt buffers uri in
let f = State.process_document ?previous_file ?contents uri in
Hashtbl.replace buffers uri f;
f

Expand Down
10 changes: 8 additions & 2 deletions server/src/state.ml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ let convert_meta_module
(meta_module_name ^ ".catala_" ^ Catala_utils.Cli.language_code language)
)

let process_document ?contents (uri : string) : t =
let process_document ?previous_file ?contents (uri : string) : t =
let open Catala_utils in
Log.info (fun m -> m "processing document '%s'" uri);
let uri = Uri.(of_string uri |> path |> pct_decode) in
Expand Down Expand Up @@ -460,7 +460,13 @@ let process_document ?contents (uri : string) : t =
List.rev !l, None, None
in
let file = create ?prog uri in
let file = { file with jump_table } in
let file =
match previous_file, jump_table with
| Some { jump_table = Some jump_table; scopelang_prg; _ }, None ->
{ file with jump_table = Some jump_table; scopelang_prg }
| _, Some jump_table -> { file with jump_table = Some jump_table }
| (None | Some _), None -> file
in
List.fold_left
(fun f (err : Catala_utils.Message.lsp_error) ->
let dummy_range =
Expand Down

0 comments on commit 71d7132

Please sign in to comment.