Skip to content

Commit

Permalink
[display] fix -D display-stdin handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Nov 29, 2023
1 parent ddef638 commit e4ca1c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/context/display/displayJson.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ class display_handler (jsonrpc : jsonrpc_handler) com (cs : CompilationCache.t)
Path.get_full_path file
) file_input_marker in
let pos = if requires_offset then jsonrpc#get_int_param "offset" else (-1) in
ignore(jsonrpc#get_opt_param (fun () ->
com.file_contents <- jsonrpc#get_opt_param (fun () ->
let s = jsonrpc#get_string_param "contents" in
let file_unique = com.file_keys#get file in
com.file_contents <- Some [file_unique, Some s];
Some s
) None);
Some [file_unique, Some s]
) None;
Parser.was_auto_triggered := was_auto_triggered;
DisplayPosition.display_position#set {
pfile = file;
Expand Down
8 changes: 7 additions & 1 deletion src/typing/typeloadParse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ let parse_file_from_string com file p string =
parse_file_from_lexbuf com file p (Sedlexing.Utf8.from_string string)

let parse_file com file p =
let file_key = com.file_keys#get file in
let contents = match com.file_contents with
| Some files ->
(try List.assoc (com.file_keys#get file) files with Not_found -> None)
(try List.assoc file_key files with Not_found -> None)
| None when (Common.defined com Define.DisplayStdin) && DisplayPosition.display_position#is_in_file file_key ->
let s = Std.input_all stdin in
close_in stdin;
com.file_contents <- Some [file_key, Some s];
Some s
| None -> None
in

Expand Down

0 comments on commit e4ca1c8

Please sign in to comment.