-
-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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 reloading scripts already in use #97168
base: master
Are you sure you want to change the base?
Fix reloading scripts already in use #97168
Conversation
Could you elaborate on the other problem? If I modify a single script externally the reload is still being fired multiple times based on a print_line() test, but maybe I'm misunderstanding something. Also, not sure if you want to fix this here, but this comment from your related previous PR is confusing. I'm assuming you meant: "The only reason the script is already loaded here is to allow editing it outside the editor, without being connected to the LSP server." godot/editor/editor_file_system.cpp Lines 1970 to 1971 in 9fd431f
|
fafc608
to
a42d379
Compare
The problem I fixed was related to using the internal editor. However, you are right — using an external editor connected to the LSP server (e.g., VSCode) was causing a double reload. If you edit the file in Notepad, for example, or use After further investigation, I found that scripts were already being reloaded twice when edited in an external editor connected via LSP — once from Additionally, I discovered that both the ScriptEditor and LSP server use Note: The
Indeed, good catch. However, I removed that comment in the new version and created a function to check if the script needs to be reloaded: I also found a bug where adding or removing exported properties in tool scripts doesn't update live when the script is saved. You need to select another node and then reselect the node to refresh the property list in the inspector. I tested this without the PR, and the same thing happens. I'll create a separate issue for that. |
a42d379
to
019ed62
Compare
019ed62
to
0522bd7
Compare
- Add documentation for issue godotengine/godot#97168 (review)
Passing the parameter
p_keep_state
toreload
inScript::reload_from_file
fixed the issue.But, I saw another problem when the scripts are opened in the editor, they were reloaded twice, once in the Script Editor and another time in EditorFileSystem. I added a check in
EditorFileSystem::_update_script_documentation
to reload script only if they are not opened in the Script Editor.