Browse Source

[display] Run `merge_core_doc` in `typerDisplay.ml` without display position (fixes #8110) (#8172)

* disable display position during `merge_core_doc` call

* run all `merge_core_doc` calls of typerDisplay without display position

* [display] fence display_position#run_outside with Std.finally
Alexander Kuzmenko 6 years ago
parent
commit
57092d8f31
2 changed files with 11 additions and 1 deletions
  1. 7 0
      src/core/display/displayPosition.ml
  2. 4 1
      src/typing/typerDisplay.ml

+ 7 - 0
src/core/display/displayPosition.ml

@@ -46,6 +46,13 @@ class display_position_container =
 		*)
 		method cut p =
 			{ p with pmax = last_pos.pmax }
+		(**
+			Temporarily reset display position, run `fn` and then restore display position.
+		*)
+		method run_outside (fn:unit->unit) =
+			let display_pos = self#get in
+			self#reset;
+			Std.finally (fun () -> self#set display_pos) fn ()
 	end
 
 let display_position = new display_position_container

+ 4 - 1
src/typing/typerDisplay.ml

@@ -21,6 +21,9 @@ let convert_function_signature ctx values (args,ret) = match DisplayEmitter.comp
 	| CompletionType.CTFunction ctf -> ((args,ret),ctf)
 	| _ -> assert false
 
+let merge_core_doc ctx mtype =
+	DisplayPosition.display_position#run_outside (fun () -> Typecore.merge_core_doc ctx mtype)
+
 let completion_item_of_expr ctx e =
 	let retype e s t =
 		try
@@ -392,7 +395,7 @@ and display_expr ctx e_ast e dk with_type p =
 			try begin
 				let _,pt = ForLoop.IterationKind.check_iterator ~resume:true ctx "keyValueIterator" e e.epos in
 				match follow pt with
-					| TAnon a -> 
+					| TAnon a ->
 						let key = PMap.find "key" a.a_fields in
 						let value = PMap.find "value" a.a_fields in
 						Some (key.cf_type,value.cf_type)