Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling type hints in editor adds extra bracket #323

Closed
boruok opened this issue Feb 24, 2022 · 3 comments · Fixed by godotengine/godot#59482
Closed

Enabling type hints in editor adds extra bracket #323

boruok opened this issue Feb 24, 2022 · 3 comments · Fixed by godotengine/godot#59482

Comments

@boruok
Copy link

boruok commented Feb 24, 2022

Issue description

func _set(property: String, value) -> bool:(  # sadface

func _set(property: String, value) -> bool:   # expected

Steps to reproduce

  1. enable add type hints in editor -> text editor -> completion -> add type hints
  2. try to type node method
@Calinou Calinou added the bug label Feb 24, 2022
@Calinou
Copy link
Member

Calinou commented Feb 24, 2022

@boruok Which Godot version and VS Code extension version are you using?

@raulsntos
Copy link
Member

I can confirm with:

  • Godot v3.4.2.stable.mono.official 45eaa2daf
  • VS Code extension compiled as of commit 12858a2

The issue seems to originate on Godot itself, since the extension receives this message from the LSP server:

{
	"id": 112,
	"jsonrpc": "2.0",
	"result": {
		"command": {
			"command": "",
			"title": ""
		},
		"data": {
			"context": null,
			"position": {
				"character": 6,
				"line": 12
			},
			"textDocument": {
				"uri": "file:///media/raulsntos/Data/GodotProjects/vscode-test/Main.gd"
			}
		},
		"deprecated": false,
		"detail": "",
		"documentation": {
			"kind": "markdown",
			"value": "\tfunc Object._set(property: String, value: Variant) -> bool\n\nVirtual method which can be overridden to customize the return value of `set`.\n\nSets a property. Returns `true` if the `property` exists.\n\n"
		},
		"filterText": "",
		"insertText": "_set(property: String, value) -> bool:(",
		"kind": 2,
		"label": "_set(property: String, value) -> bool:",
		"preselect": false,
		"sortText": ""
	}
}

Notice the property insertText that already includes the closing parenthesis.

The code responsible is: https://github.com/godotengine/godot/blob/4dc8214831d1617e7f5f06e8294fb37ea23dae59/modules/gdscript/language_server/gdscript_text_document.cpp#L287-L291 (affects both master and 3.x).

Godot adds the closing parenthesis when the label doesn't end with ):, this works when not using type hints since the label would be:

_set(property, value):

But doesn't work when using type hints since the label no longer ends with )::

_set(property: String, value) -> bool:

@boruok
Copy link
Author

boruok commented Feb 25, 2022

@Calinou
godot-tools v1.1.3
v3.4.3.rc2.official [0ea54d07f]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment