diff options
author | Emmanuel Barroga <emmanuelbarroga@gmail.com> | 2019-08-06 23:41:10 -0700 |
---|---|---|
committer | Emmanuel Barroga <emmanuelbarroga@gmail.com> | 2019-08-06 23:57:14 -0700 |
commit | 0d8c7c30a025e674567fafcef91ac86d784d536e (patch) | |
tree | 1324534c739e8dff73ea209469c0de83f7efc681 /editor | |
parent | 52cfb5f5799af38e4aa543417a76999b732c3a54 (diff) |
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')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 24 | ||||
-rw-r--r-- | editor/plugins/text_editor.cpp | 5 | ||||
-rw-r--r-- | editor/plugins/text_editor.h | 1 |
3 files changed, 26 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); + } + } } } } diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 34d8e6aff5..a8fbadb773 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -313,6 +313,11 @@ void TextEditor::goto_line(int p_line, bool p_with_error) { code_editor->goto_line(p_line); } +void TextEditor::goto_line_selection(int p_line, int p_begin, int p_end) { + + code_editor->goto_line_selection(p_line, p_begin, p_end); +} + void TextEditor::set_executing_line(int p_line) { code_editor->set_executing_line(p_line); diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index 3a330576ae..c0d4052646 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -131,6 +131,7 @@ public: virtual Vector<String> get_functions(); virtual void get_breakpoints(List<int> *p_breakpoints); virtual void goto_line(int p_line, bool p_with_error = false); + void goto_line_selection(int p_line, int p_begin, int p_end); virtual void set_executing_line(int p_line); virtual void clear_executing_line(); virtual void trim_trailing_whitespace(); |