diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 4d8936fc58b..53c8a634392 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3618,6 +3618,8 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_lambda(ExpressionNode *p_p bool multiline_context = multiline_stack.back()->get(); + push_completion_call(nullptr); + // Reset the multiline stack since we don't want the multiline mode one in the lambda body. push_multiline(false); if (multiline_context) { @@ -3665,6 +3667,8 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_lambda(ExpressionNode *p_p pop_multiline(); + pop_completion_call(); + if (multiline_context) { // If we're in multiline mode, we want to skip the spurious DEDENT and NEWLINE tokens. while (check(GDScriptTokenizer::Token::DEDENT) || check(GDScriptTokenizer::Token::INDENT) || check(GDScriptTokenizer::Token::NEWLINE)) { diff --git a/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_body.cfg b/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_body.cfg new file mode 100644 index 00000000000..37140354001 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_body.cfg @@ -0,0 +1,7 @@ +[output] +include=[ + {"display": "print(…)", "insert_text": "print("}, +] +exclude=[ + {"insert_text": "print"}, +] diff --git a/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_body.gd b/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_body.gd new file mode 100644 index 00000000000..41edc23a803 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_body.gd @@ -0,0 +1,5 @@ +signal test_signal + +func _init() -> void: + test_signal.connect(func(): p➡ + pass diff --git a/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_parameter.cfg b/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_parameter.cfg new file mode 100644 index 00000000000..37140354001 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_parameter.cfg @@ -0,0 +1,7 @@ +[output] +include=[ + {"display": "print(…)", "insert_text": "print("}, +] +exclude=[ + {"insert_text": "print"}, +] diff --git a/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_parameter.gd b/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_parameter.gd new file mode 100644 index 00000000000..c2930f01b42 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/no_parenthesis_when_callable_is_expected/lambda_parameter.gd @@ -0,0 +1,5 @@ +signal test_signal + +func _init() -> void: + test_signal.connect(func(a = p➡): pass + pass