godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.54k stars 163 forks source link

InputEvent.is_action_pressed have wrong and different parameter completion behavior to Input.is_action_pressed #573

Closed kaluluosi closed 8 months ago

kaluluosi commented 8 months ago

Godot version

4.2.1 -stable

VS Code version

1.64.2

Godot Tools VS Code extension version

2.0

System information

Win10, Core I7-9700,RTX2080

Issue description

When you type in event.is_action_pressed, it pops up an input action list for you to insert. After you press enter to insert, you find that it also inserts its own double quotes for you and doesn't clean up the double quotes that you input.

image

extends Control

func _ready():
    var event = InputEventKey.new()
    event.is_action_pressed(""ui_accept""

But it won't happen on Input.is_action_pressed.

image

extends Control

func _ready():
    Input.is_action_pressed("ui_cancel")

PS: It not happens in Godot Editor, just happens in VSCode.

While typing Input.is_action_pressed, it's LSP request and response Input request It respondd the completion item kind is 2 -> lsp::CompletionItemKind::Method Input response Input lsp

In the case of InputEvent.is_action_pressed, it's LSP request and response InputEvent request It responds the completion item kind is 21 -> lsp::CompletionItemKind::Constant InputEvent response InputEvent lsp

And I find something interesting in GodotScript LSP server.

While typing InputEvent.is_action_pressed. In the method _find_call_arguments: image And because the base is nil, so it is not considered as a method. image

And this is the case of Input.is_action_presss: The LSP server has identified the type of Input. image image

It seems that there has a hard code to force fix the issue of InputEvent not identified. It force return the input action options as CODE_COMPLETION_KIND_CONSTANT. image

I can simply fix it by change CODE_COMPLETION_KIND_CONSTANT to CODE_COMPLETION_KIND_FUNCTION image

image

But it may not the best way to fix it. The best way is to find out why LSP server can't identify the type of InputEvent and figure it,

Steps to reproduce

All in description.

DaelonSuzuka commented 8 months ago

This is a problem with the language server, which is a component of the Godot Editor. This extension doesn't have anything to do with that.

You'll need to go open an issue with the engine, and you can propose your fix there.

kaluluosi commented 8 months ago

This is a problem with the language server, which is a component of the Godot Editor. This extension doesn't have anything to do with that.

You'll need to go open an issue with the engine, and you can propose your fix there.

yep, I have report it to the Godot Engine. Thanks . I close this issue.