2
0
Эх сурвалжийг харах

[display] fix -D display-stdin handling

Rudy Ges 1 жил өмнө
parent
commit
e4ca1c81f0

+ 3 - 4
src/context/display/displayJson.ml

@@ -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;

+ 7 - 1
src/typing/typeloadParse.ml

@@ -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