Browse Source

[display] always cut replaceRange at display position

closes #7251
Simon Krajewski 7 years ago
parent
commit
2e8b7e46f7

+ 0 - 1
src/compiler/main.ml

@@ -1037,7 +1037,6 @@ with
 			begin match ctx.com.json_out with
 			| Some (f,_) ->
 				let ctx = DisplayJson.create_json_context false in
-				let pos = Parser.cut_pos_at_display pos in
 				let path = match List.rev p with
 					| name :: pack -> List.rev pack,name
 					| [] -> [],""

+ 1 - 1
src/context/display/displayException.ml

@@ -42,7 +42,7 @@ let fields_to_json ctx fields kind po =
 	let fl =
 		("items",jarray ja) ::
 		("mode",CompletionResultKind.to_json ctx kind) ::
-		(match po with None -> [] | Some p -> ["replaceRange",generate_pos_as_range p]) in
+		(match po with None -> [] | Some p -> ["replaceRange",generate_pos_as_range (Parser.cut_pos_at_display p)]) in
 	jobject fl
 
 let to_json ctx de =

+ 1 - 1
src/typing/typer.ml

@@ -1344,7 +1344,7 @@ and handle_efield ctx e p mode =
 									(* if there was no module name part, last guess is that we're trying to get package completion *)
 									if ctx.in_display then begin
 										if ctx.com.json_out = None then raise (Parser.TypePath (List.map (fun (n,_,_) -> n) (List.rev acc),None,false,p))
-										else raise_fields (DisplayToplevel.collect ctx TKType NoValue) CRTypeHint (Some (Parser.cut_pos_at_display p0));
+										else raise_fields (DisplayToplevel.collect ctx TKType NoValue) CRTypeHint (Some p0);
 									end;
 									raise e)
 		in

+ 2 - 2
src/typing/typerDisplay.ml

@@ -390,14 +390,14 @@ let handle_display ctx e_ast dk with_type =
 		type_expr ctx e_ast with_type
 	with Error (Unknown_ident n,_) when ctx.com.display.dms_kind = DMDefault ->
         if dk = DKDot && ctx.com.json_out = None then raise (Parser.TypePath ([n],None,false,p))
-		else raise_toplevel ctx dk with_type (Some (Parser.cut_pos_at_display p)) p
+		else raise_toplevel ctx dk with_type (Some p) p
 	| Error ((Type_not_found (path,_) | Module_not_found path),_) as err when ctx.com.display.dms_kind = DMDefault ->
 		if ctx.com.json_out = None then	begin try
 			raise_fields (DisplayFields.get_submodule_fields ctx path) (CRField((make_ci_module path),p)) None
 		with Not_found ->
 			raise err
 		end else
-			raise_toplevel ctx dk with_type (Some (Parser.cut_pos_at_display p)) p
+			raise_toplevel ctx dk with_type (Some p) p
 	| DisplayException(DisplayFields(l,CRTypeHint,p)) when (match fst e_ast with ENew _ -> true | _ -> false) ->
 		let timer = Timer.timer ["display";"toplevel";"filter ctors"] in
 		ctx.pass <- PBuildClass;