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

Fix external editor hot reload for GDScript #82986

Merged

Conversation

OmarShehata
Copy link
Contributor

Fixes #72825 by adding a call to:

ScriptEditor::get_singleton()->trigger_live_script_reload();

in the GDScriptTextDocument::didSave callback. I tested this using the VSCode Godot extension, when connected to the language server, in master saving the file in VSCode does NOT trigger an update. An update only happens when you focus in the editor, which goes through the flow: ScriptEditor::_notification -> _update_modified_scripts_for_external_editor().

https://github.com/godotengine/godot/blob/6916349697a4339216469e9bf5899b983d78db07/editor/plugins/script_editor_plugin.cpp#L1677C4-L1677C48

For reference, the normal flow of updating a script file while the game is running goes through ScriptEditor::_res_saved_callback() -> _trigger_live_script_reload()

@pchan3
Copy link

pchan3 commented Oct 11, 2023

@OmarShehata

I am currently using Jetbrains Rider & C#. The issue I experience is that If I have a Node open in the editor with a C# script attached. Make a change in Rider to the script & save. Then make a change to an export variable in the inspector and then save. The behaviour is that the script reverts and Rider does a hot reload and I lose my changes.

I have compiled this particular PR and I am able replicate the bug in it.

Is this PR catering for my scenario or is my issue different?

@akien-mga akien-mga changed the title Fix external editor hot reload Fix external editor hot reload for GDScript Oct 11, 2023
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
Copy link
Member

@pchan3 This PR only changes things for the GDScript LSP, not for C# editors.

@pchan3
Copy link

pchan3 commented Oct 11, 2023

@pchan3 This PR only changes things for the GDScript LSP, not for C# editors.

Should I raise this as a new bug?

@akien-mga
Copy link
Member

@pchan3 I believe your issue is already tracked here: #50163

@akien-mga akien-mga merged commit 25fa5ea into godotengine:master Oct 11, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@muhajirdev
Copy link

muhajirdev commented Oct 15, 2023

is this already in the latest beta @OmarShehata , how do I try it?

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.

Hot-reloading of scripts ("Synchronize Script Changes") doesn't work when using external editor (VSCode)
5 participants