Improve warnings when running scripts in the editor #81022
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.
So I noticed that when a script has errors (caught by the analyzer in case of GDScript), if we try to run it in the editor the reported warning is incorrect and misleading:
That's probably because the tool flag on the script is not set if the script fails the analyzer checks. That may change in the future, but after looking at the code, I think the order of checks in the editor itself is wrong. So I've changed it, and also made these warnings into toasts instead of blocking popups. Seems more appropriate this way, and I adjusted the messages that are shown.
EditorScript
.This order ensures that the latter checks are done on a freshly reloaded version of the script, and before that we actually try to parse it and see if it's valid.
While looking up how to do the toasts I noticed one of them was missing the translation macro, so I added that.