summaryrefslogtreecommitdiffstats
path: root/editor/plugins/script_editor_plugin.cpp
diff options
context:
space:
mode:
authorEmmanuel Barroga <emmanuelbarroga@gmail.com>2019-08-06 23:41:10 -0700
committerEmmanuel Barroga <emmanuelbarroga@gmail.com>2019-08-06 23:57:14 -0700
commit0d8c7c30a025e674567fafcef91ac86d784d536e (patch)
tree1324534c739e8dff73ea209469c0de83f7efc681 /editor/plugins/script_editor_plugin.cpp
parent52cfb5f5799af38e4aa543417a76999b732c3a54 (diff)
downloadredot-engine-0d8c7c30a025e674567fafcef91ac86d784d536e.tar.gz
Fix Find in Files Not Working Properly
When using the "Find in Files" option to search in non-script files (e.g. .tscn), the search does not work properly.
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r--editor/plugins/script_editor_plugin.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 9418349d71..02d4b9d1d7 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -44,6 +44,7 @@
#include "editor/script_editor_debugger.h"
#include "scene/main/viewport.h"
#include "script_text_editor.h"
+#include "text_editor.h"
/*** SCRIPT EDITOR ****/
@@ -2995,11 +2996,26 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb
shader_editor->make_visible(true);
shader_editor->get_shader_editor()->goto_line_selection(line_number - 1, begin, end);
} else {
- edit(res);
+ Ref<Script> script = res;
+ if (script.is_valid()) {
+ edit(script);
+
+ ScriptTextEditor *ste = Object::cast_to<ScriptTextEditor>(_get_current_editor());
+ if (ste) {
+ ste->goto_line_selection(line_number - 1, begin, end);
+ }
+ } else { //if file is not valid script, load as text file
- ScriptTextEditor *ste = Object::cast_to<ScriptTextEditor>(_get_current_editor());
- if (ste) {
- ste->goto_line_selection(line_number - 1, begin, end);
+ Error err;
+ Ref<TextFile> text_file = _load_text_file(fpath, &err);
+ if (text_file.is_valid()) {
+ edit(text_file);
+
+ TextEditor *te = Object::cast_to<TextEditor>(_get_current_editor());
+ if (te) {
+ te->goto_line_selection(line_number - 1, begin, end);
+ }
+ }
}
}
}