diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-08-07 11:56:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-07 11:56:18 +0200 |
commit | a909efeb120afcb41f2c67720e7638ece0a6d6ff (patch) | |
tree | 71f3c87e6ba7b6c03a279231aed429ef5db40c0f /editor/plugins/script_editor_plugin.cpp | |
parent | f5f16e57fdbae84c063bb0c2e6185921e719f3c3 (diff) | |
parent | 0d8c7c30a025e674567fafcef91ac86d784d536e (diff) |
Merge pull request #31173 from sparkart/search_in_tscn
Fix Find in Files Not Working Properly
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 24 |
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); + } + } } } } |