summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-05-05 16:49:15 +0200
committerGitHub <noreply@github.com>2020-05-05 16:49:15 +0200
commit4d50f747d5250e88cf2c35039af23eb3ac28aa4f (patch)
tree7349071eea52d9ea287c03003176893ea58fb1b9 /editor/plugins
parent8227947d41eadc00ccbd3c2ddbcf83daa3591208 (diff)
parentbe7a353c70812e349861a7f5314d72425ae707cb (diff)
Merge pull request #37293 from Janglee123/ctrl-click-improvements
Improved go-to definition (Ctrl + Click)
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/script_text_editor.cpp37
-rw-r--r--editor/plugins/script_text_editor.h2
2 files changed, 38 insertions, 1 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 1a77eeb9de..c79c97737a 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -978,6 +978,26 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
emit_signal("go_to_help", "class_global:" + result.class_name + ":" + result.class_member);
} break;
}
+ } else if (ProjectSettings::get_singleton()->has_setting("autoload/" + p_symbol)) {
+ //check for Autoload scenes
+ String path = ProjectSettings::get_singleton()->get("autoload/" + p_symbol);
+ if (path.begins_with("*")) {
+ path = path.substr(1, path.length());
+ EditorNode::get_singleton()->load_scene(path);
+ }
+ } else if (p_symbol.is_rel_path()) {
+ // Every symbol other than absolute path is relative path so keep this condition at last.
+ String path = _get_absolute_path(p_symbol);
+ if (FileAccess::exists(path)) {
+ List<String> scene_extensions;
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
+
+ if (scene_extensions.find(path.get_extension())) {
+ EditorNode::get_singleton()->load_scene(path);
+ } else {
+ EditorNode::get_singleton()->load_resource(path);
+ }
+ }
}
}
@@ -991,13 +1011,28 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) {
}
ScriptLanguage::LookupResult result;
- if (ScriptServer::is_global_class(p_symbol) || p_symbol.is_resource_file() || script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK) {
+ if (ScriptServer::is_global_class(p_symbol) || p_symbol.is_resource_file() || script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK || ProjectSettings::get_singleton()->has_setting("autoload/" + p_symbol)) {
text_edit->set_highlighted_word(p_symbol);
+ } else if (p_symbol.is_rel_path()) {
+
+ String path = _get_absolute_path(p_symbol);
+ if (FileAccess::exists(path)) {
+ text_edit->set_highlighted_word(p_symbol);
+ } else {
+ text_edit->set_highlighted_word(String());
+ }
+
} else {
text_edit->set_highlighted_word(String());
}
}
+String ScriptTextEditor::_get_absolute_path(const String &rel_path) {
+ String base_path = script->get_path().get_base_dir();
+ String path = base_path.plus_file(rel_path);
+ return path.replace("///", "//").simplify_path();
+}
+
void ScriptTextEditor::update_toggle_scripts_button() {
if (code_editor != nullptr) {
code_editor->update_toggle_scripts_button();
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 51ce30c831..a0dfba6cc8 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -188,6 +188,8 @@ protected:
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
+ String _get_absolute_path(const String &rel_path);
+
public:
void _update_connected_methods();