-
-
Notifications
You must be signed in to change notification settings - Fork 21.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
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)
0522bd7
to
958f519
Compare
Not sure if related, but there is a bug where trying to run a build-in tool script (with File -> Run) will make it completely unable to be modified until editor restart (even closing and re-opening the scene will not help). It prints the same "already in use error"). Example: @tool
extends Node
func _process(delta: float) -> void:
print("A") It will keep printing A. Change it to B and it will print B. Press Ctrl+Shift+X, you will get error in the console and any further script modifications will be ignored. I can open a new issue, but since it involves the same error, I though you could fix it too. |
It's definitively related, once you get the |
958f519
to
a3c5e5a
Compare
I tested your script with this PR and it fixes the issue. I can update the script inside Godot, External script with LSP or not and it's updating perfectly! The only problem was that the first time that I attached the script to a node, I has to close and reopen the scene. I think this PR should fix that issue: #92099 |
It does not for me. godot.windows.editor.dev.x86_64_T0WmKhy2i1.mp4 |
a3c5e5a
to
9638220
Compare
My bad, I tested it too quickly. The issue you're describing existed in 4.3 stable when trying to run a tool script that was still in memory. It's the same problem: before running the script, a I also retested with an I searched through the codebase, and the only places where |
Thanks! |
Is there any chance we can get this fix cherry-picked for 4.3.1? It's painful to work on tool scripts without it right now on 4.3. |
This is a fix for a regression specific to 4.4, I don't think it's applicable as is to 4.3. Do you have a bug report detailing what issue you have in 4.3? |
This same error and behavior happens in 4.3 for I can open a separate issue to document it if necessary. |
Opened #97280 to reflect a similar problem in 4.3. |
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.