Implement applyEdit in LSP for signal connecting #50378
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As per the discussion in #42416, when an external text editor is set, the Connect Dialog fails to actually enact any change into the script. The workaround currently is to disable external editor, connect your signals, then re-enable it (or work in an external editor even with it turned off.)
This PR implements the workspace/applyEdit server request, which can cause a connected client to insert or replace text - in this case, a blank method stub. By connecting to the EditorNode, we can detect the "script_add_function_request" signal and pass the new function along to the client.
## Known IssuesCurrently, once the script has been saved, its changes are not detected by Godot, so the "Go to method" menu item fails, and it will try to add duplicate functions if it already exists. This is fixed by the as yet unmerged #48615, which forces a resync by the server whenever a script is saved.That PR has been merged in, so it's no longer an issue - so long as you save your script.