Procházet zdrojové kódy

[display] only auto-trigger-signature-complete if on an actual call argument

Simon Krajewski před 7 roky
rodič
revize
be6f08ed67

+ 9 - 3
src/context/display/display.ml

@@ -93,9 +93,15 @@ module ExprPreprocessing = struct
 	let find_display_call e =
 		let found = ref false in
 		let loop e = match fst e with
-			| ECall _ | ENew _ when not !found && is_display_position (pos e) ->
-				found := true;
-				Parser.mk_display_expr e DKCall
+			| ECall(_,el) | ENew(_,el) when not !found && is_display_position (pos e) ->
+				let call_arg_is_marked () =
+					List.exists (fun (e,_) -> match e with EDisplay(_,DKMarked) -> true | _ -> false) el
+				in
+				if not !Parser.was_auto_triggered || call_arg_is_marked () then begin
+					found := true;
+					Parser.mk_display_expr e DKCall
+				end else
+					e
 			| _ -> e
 		in
 		let rec map e = loop (Ast.map_expr map e) in

+ 19 - 0
tests/display/src/cases/Issue7063.hx

@@ -0,0 +1,19 @@
+package cases;
+
+class Issue7063 extends DisplayTestCase {
+	/**
+	class Main {
+		public static function main() {
+			call({
+				foo: 1,{-1-}
+			});
+		}
+
+		static function call(arg1:Dynamic, arg2:Int) { }
+	}
+	**/
+	function test() {
+		// assumes wasAutoTriggered = false, update test for new protocol
+		sigEq(0, [["arg1:Dynamic", "arg2:Int"]], signature(pos(1)));
+	}
+}