Skip to content

Make file part of errors/warnings clickable in Output panel #108473

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mihe
Copy link
Contributor

@mihe mihe commented Jul 10, 2025

Fixes godotengine/godot-proposals#1628.
Fixes godotengine/godot-proposals#10000.
Relates to #57896.
Relates to #87216.

This makes the file and line part of error messages in the Output panel clickable, by simply wrapping both in a [url] BBCode tag, parsing those URIs in EditorLog::_meta_clicked and then opening the file in much the same way as the editor normally would, either in the built-in script editor or external editor, depending on the user's editor settings.

This PR takes a more conservative approach compared to #57896, by not trying to find every possible URL in the log and instead only concerning itself with the thing we already know is a file path, which saves us from any costly/error-prone parsing of the log itself.

One potentially controversial change here is that EditorLog::_meta_clicked will now early-out if it gets passed an invalid URI, meaning anything that doesn't start with something like res:, file:, mailto: or whatever else. The reason for this being that errors/warnings emitted from C++ will include relative file paths (e.g. editor/editor_log.cpp:201) which I couldn't see an easy way to deal with, and forwarding those to OS::shell_open will typically open the user's browser at that (bogus) path, so I opted to have it do nothing instead.

We could of course just not wrap the relative C++ paths in [url] to begin with, but again, I wanted to avoid any type of costly/error-prone parsing during logging if possible.

I'm happy to change it back to default to OS::shell_open for all non-URIs, but I figure since the express intent of #87216 was to allow for things like file: and mailto: then this behavior might be desirable anyway.

@hsvfan-jan
Copy link

hsvfan-jan commented Jul 10, 2025

This seems to also close godotengine/godot-proposals#10000 I think

edit: seems like you added that to the description while I was making my comment :D

@mihe mihe requested a review from Calinou July 10, 2025 10:26
@mihe mihe force-pushed the clickable-diagnostics branch from 230206c to 49c615b Compare July 10, 2025 11:43
@ydeltastar
Copy link
Contributor

ydeltastar commented Jul 14, 2025

only concerning itself with the thing we already know is a file path

Does this also work for print_debug()?

@mihe
Copy link
Contributor Author

mihe commented Jul 14, 2025

Does this also work for print_debug()?

No. Those paths are not added (or otherwise parsed) in EditorLog, so would require parsing of the log messages. Same goes for print_stack().

I'd prefer to keep this PR limited to errors/warnings, since that's what the two proposals are about.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally, it works as expected. Code looks good to me.

image

However, note this only applies to the Output tab. Errors/warnings are only visible if they were printed by the editor, which means only @tool scripts will benefit from this change (as errors/warnings printed in the running project appear in the Debugger > Errors tab instead).

Also, links to C++ source files will appear to be clickable, but will do nothing when clicked.

@mihe
Copy link
Contributor Author

mihe commented Jul 25, 2025

which means only @tool scripts will benefit from this change

The main motivation for this was being able to click the paths of GDScript parse errors, where this also applies.

errors/warnings printed in the running project appear in the Debugger > Errors tab instead

Indeed, and those are clickable already.

Also, links to C++ source files will appear to be clickable, but will do nothing when clicked.

Yes, that would be the "potentially controversial change" mentioned in the PR description.

I was toying with the idea of maybe being able to open up GitHub links to the actual file and line for C++ errors, since we should have the commit and everything, but that probably gets messy very quickly, especially when you start involving custom forks, custom modules and godot-cpp errors and whatever else there might be.

@mihe mihe modified the milestones: 4.x, 4.6 Jul 25, 2025
@mihe mihe force-pushed the clickable-diagnostics branch from 49c615b to 04d6e89 Compare July 26, 2025 08:52
@mihe mihe requested a review from a team as a code owner July 26, 2025 08:52
@mihe
Copy link
Contributor Author

mihe commented Jul 26, 2025

I forgot to escape [ in the other err_str case. Should be fixed now.

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.

Make console file path errors clickable Make script paths in Editor Output error messages clickable
4 participants