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

LSP: Fix wrong parentheses for function call autocompletion #59482

Merged
merged 1 commit into from
Jun 15, 2022

Conversation

kurtlachmann
Copy link
Contributor

GDScriptLanguage::complete_code() already defines its own insert_text field. Instead of coming up with our own (naive) logic we should reuse that. It also adds the parentheses to function calls but its algorithm is smarter and already considers edge cases like e.g. type hints.

For this to have any effect we also have to send the insertText field already during the completionRequest and not only during resolve. But this is actually the recommended behavior according to the LSP specification so it's a step in the right direction anyway.

@kurtlachmann kurtlachmann requested a review from a team as a code owner March 24, 2022 19:07
* GDScriptLanguage::complete_code already adds parentheses to function calls, and does this a lot smarter than the language server right now.
* Instead of the previous naive approach we now reuse the same logic as the internal editor.
* For this to have any effect we also have to send the `insertText` field already during the completionRequest and not only during resolve.
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@akien-mga akien-mga merged commit 9839761 into godotengine:master Jun 15, 2022
@akien-mga
Copy link
Member

Thanks!

@Calinou
Copy link
Member

Calinou commented Jun 15, 2022

Is this eligible for a 3.x cherry-pick? This would be needed to also fix godotengine/godot-vscode-plugin#184 in 3.x.

@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jun 15, 2022
@akien-mga
Copy link
Member

Cherry-picked for 3.5.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enabling type hints in editor adds extra bracket Connect signal method adds parentheses
4 participants