X Tutup
Skip to content

Open source code errors in external editor#111805

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
KoBeWi:open_source_be_like
Nov 5, 2025
Merged

Open source code errors in external editor#111805
Repiteo merged 1 commit intogodotengine:masterfrom
KoBeWi:open_source_be_like

Conversation

@KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Oct 18, 2025

Errors in the Output are now clickable, but the errors from engine's source code do not open properly. The path includes : (line number) so using shell_open() will always fail.

This PR fixes it, but I went a step further, and made the errors automatically opened in external editor if it's configured.

godot.windows.editor.dev.x86_64_pA1wQuwbXd.mp4

@KoBeWi KoBeWi added this to the 4.6 milestone Oct 18, 2025
@KoBeWi KoBeWi requested a review from a team as a code owner October 18, 2025 22:05
@KoBeWi KoBeWi requested a review from a team October 18, 2025 22:05
Copy link
Contributor

@kitbdev kitbdev left a comment

Choose a reason for hiding this comment

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

Looks good.
Note that this is only useful for engine developers since you need to compile the engine yourself to get the absolute paths needed, otherwise nothing happens.

@Calinou
Copy link
Member

Calinou commented Oct 28, 2025

Errors use relative paths for C++ stack traces on my Linux system (using debug_symbols=yes), so this won't work there:

image

This also applies to errors printed to the Output panel.

We could support an editor setting that defines the Godot source code location, so that the path can be resolved. Alternatively, you could try to resolve a path relative to the editor binary location (with ../ prepended).

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 28, 2025

How did you enable relative paths?

@Repiteo
Copy link
Contributor

Repiteo commented Oct 28, 2025

I think that's just a default option for many compilers. It can be explicitly overridden via -fdiagnostics-absolute-paths on clang, for instance

@KoBeWi KoBeWi force-pushed the open_source_be_like branch 2 times, most recently from d4ec057 to 12de363 Compare October 28, 2025 22:01
@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 28, 2025

It should be fixed now.

@Repiteo Repiteo requested a review from Calinou October 29, 2025 18:04
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.

On Linux, nothing happens when I click the error here:

image
@tool
extends Node


func _ready() -> void:
	push_error("test")

My settings are set this way, it works for GDScript files:

image

I restarted the editor after changing the external editor settings, but it didn't help. I don't see anything more being printed to stdout/stderr, even with verbose mode.

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 30, 2025

The relative paths are handled correctly, but the regex fails to match them. I don't even know why is it there.

godot/editor/editor_log.cpp

Lines 203 to 206 in e4c9950

Ref<RegExMatch> uri_match = RegEx(R"(^([a-zA-Z][a-zA-Z0-9+.-]*):(?://)?(.+?)(?::([0-9]+))?$)").search(p_meta);
if (uri_match.is_null()) {
return;
}

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 31, 2025

@Calinou Please test again.
I removed the regex completely.

@akien-mga akien-mga requested a review from Calinou November 1, 2025 17:34
@KoBeWi KoBeWi force-pushed the open_source_be_like branch from 0c61ff1 to 02a0595 Compare November 3, 2025 20:14
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.

Works great now 🙂 Code looks good to me.

Note that I had to replace if (ignore_project) with if (p_ignore_project) to get it to build locally, so you should do that to fix CI.

@KoBeWi KoBeWi force-pushed the open_source_be_like branch from 02a0595 to edceae1 Compare November 4, 2025 23:53
@Repiteo Repiteo merged commit 9d8d6fd into godotengine:master Nov 5, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 5, 2025

Thanks!

@KoBeWi KoBeWi deleted the open_source_be_like branch November 5, 2025 17:53
@GustJc
Copy link
Contributor

GustJc commented Nov 13, 2025

I got a bit confused by this feature. I thought it would link to the code inside github at first.
I get that opening the local file is a very useful feature for debugging in dev.
But it might be confusing for people that are using the engine.

Here's what happen: When opening Godot Editor with no dev environment, I clicked the error link, but then it just opened vscode with an empty new file named after the cpp file that gave the error.

This could confuse the engine users to think this is a bug.

So it might be a good idea to link to github instead by default in the release version.
Make it toggleable in the EditorSettings, or check if the file exists and go from there.

Unless I'm missing something?

@KoBeWi
Copy link
Member Author

KoBeWi commented Nov 13, 2025

it just opened vscode with an empty new file named after the cpp file that gave the error.

This shouldn't be happening, it's supposed to open the file only if it exists.

So it might be a good idea to link to github instead by default in the release version.

I can try that.

@GustJc
Copy link
Contributor

GustJc commented Nov 18, 2025

This shouldn't be happening, it's supposed to open the file only if it exists.

Just for reference, here's a video.

link.error.mp4

It only happens because I have vscode setup as the external text editor.
But I don't think it should be happening if it doesn't find the file.

So it might be a good idea to link to github instead by default in the release version.

I can try that.

That would be awesome. Even though I have Godot source here, I often prefer to go to github to browse the code if I'm just trying to understand something simple. It would be very helpful if it did so when the file is not present, or even with an editor setting toggle.

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.

6 participants

X Tutup