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

Improve warnings when running scripts in the editor #81022

Merged

Conversation

YuriSizov
Copy link
Contributor

@YuriSizov YuriSizov commented Aug 26, 2023

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:

godot windows editor dev x86_64_2023-08-25_19-39-34

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.

  • First we check if it's a script at all (you can run the command for text files, for example).
  • Then we try to reload the script and check if that went successfully; we also check if the script is valid.
  • Then we check if it's a tool script.
  • Then we check if it inherits 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.

godot windows editor dev x86_64_2023-08-26_20-34-04 godot windows editor dev x86_64_2023-08-26_20-34-28 godot windows editor dev x86_64_2023-08-26_20-34-59

While looking up how to do the toasts I noticed one of them was missing the translation macro, so I added that.

@YuriSizov YuriSizov added this to the 4.2 milestone Aug 26, 2023
@YuriSizov YuriSizov requested a review from a team as a code owner August 26, 2023 18:49
@YuriSizov YuriSizov force-pushed the editor-run-scripts-valid-and-toasty branch from 11707a2 to 2270f49 Compare August 27, 2023 11:59
@YuriSizov
Copy link
Contributor Author

Two warnings for the price of one!

image

Copy link
Member

@dalexeev dalexeev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes look good to me, including toaster notifications!

@akien-mga akien-mga merged commit 00d1faf into godotengine:master Aug 28, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@YuriSizov YuriSizov deleted the editor-run-scripts-valid-and-toasty branch August 28, 2023 10:38
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.

3 participants