You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Open source code errors in external editor
This commit is contained in:
@@ -200,20 +200,30 @@ void EditorLog::_load_state() {
|
||||
}
|
||||
|
||||
void EditorLog::_meta_clicked(const String &p_meta) {
|
||||
Ref<RegExMatch> uri_match = RegEx(R"(^([a-zA-Z][a-zA-Z0-9+.-]*):(?://)?(.+?)(?::([0-9]+))?$)").search(p_meta);
|
||||
if (uri_match.is_null()) {
|
||||
if (!p_meta.contains_char(':')) {
|
||||
return;
|
||||
}
|
||||
const PackedStringArray parts = p_meta.rsplit(":", true, 1);
|
||||
String path = parts[0];
|
||||
const int line = parts[1].to_int() - 1;
|
||||
|
||||
String scheme = uri_match->get_string(1);
|
||||
if (scheme == "res") {
|
||||
String file = uri_match->get_string(2);
|
||||
int line = (int)uri_match->get_string(3).to_int();
|
||||
if (ResourceLoader::exists(file)) {
|
||||
Ref<Resource> res = ResourceLoader::load(file);
|
||||
ScriptEditor::get_singleton()->edit(res, line - 1, 0);
|
||||
if (path.begins_with("res://")) {
|
||||
if (ResourceLoader::exists(path)) {
|
||||
const Ref<Resource> res = ResourceLoader::load(path);
|
||||
ScriptEditor::get_singleton()->edit(res, line, 0);
|
||||
InspectorDock::get_singleton()->edit_resource(res);
|
||||
}
|
||||
} else if (path.has_extension("cpp") || path.has_extension("h") || path.has_extension("mm") || path.has_extension("hpp")) {
|
||||
// Godot source file. Try to open it in external editor.
|
||||
if (path.begins_with("./") || path.begins_with(".\\")) {
|
||||
// Relative path. Convert to absolute, using executable path as reference.
|
||||
path = path.trim_prefix("./").trim_prefix(".\\");
|
||||
path = OS::get_singleton()->get_executable_path().get_base_dir().get_base_dir().path_join(path);
|
||||
}
|
||||
|
||||
if (!ScriptEditorPlugin::open_in_external_editor(path, line, -1, true)) {
|
||||
OS::get_singleton()->shell_open(path);
|
||||
}
|
||||
} else {
|
||||
OS::get_singleton()->shell_open(p_meta);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user