Fix error when going to a text file by clicking in a result from "Find in files"
This commit is contained in:
parent
05be97a607
commit
699afca7ef
2 changed files with 29 additions and 23 deletions
|
@ -524,6 +524,7 @@ FindInFilesPanel::FindInFilesPanel() {
|
||||||
|
|
||||||
_progress_bar = memnew(ProgressBar);
|
_progress_bar = memnew(ProgressBar);
|
||||||
_progress_bar->set_h_size_flags(SIZE_EXPAND_FILL);
|
_progress_bar->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
_progress_bar->set_v_size_flags(SIZE_SHRINK_CENTER);
|
||||||
hbc->add_child(_progress_bar);
|
hbc->add_child(_progress_bar);
|
||||||
set_progress_visible(false);
|
set_progress_visible(false);
|
||||||
|
|
||||||
|
|
|
@ -2989,12 +2989,15 @@ void ScriptEditor::_on_find_in_files_requested(String text) {
|
||||||
|
|
||||||
void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) {
|
void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) {
|
||||||
|
|
||||||
|
if (ResourceLoader::exists(fpath)) {
|
||||||
RES res = ResourceLoader::load(fpath);
|
RES res = ResourceLoader::load(fpath);
|
||||||
|
|
||||||
if (fpath.get_extension() == "shader") {
|
if (fpath.get_extension() == "shader") {
|
||||||
ShaderEditorPlugin *shader_editor = Object::cast_to<ShaderEditorPlugin>(EditorNode::get_singleton()->get_editor_data().get_editor("Shader"));
|
ShaderEditorPlugin *shader_editor = Object::cast_to<ShaderEditorPlugin>(EditorNode::get_singleton()->get_editor_data().get_editor("Shader"));
|
||||||
shader_editor->edit(res.ptr());
|
shader_editor->edit(res.ptr());
|
||||||
shader_editor->make_visible(true);
|
shader_editor->make_visible(true);
|
||||||
shader_editor->get_shader_editor()->goto_line_selection(line_number - 1, begin, end);
|
shader_editor->get_shader_editor()->goto_line_selection(line_number - 1, begin, end);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
Ref<Script> script = res;
|
Ref<Script> script = res;
|
||||||
if (script.is_valid()) {
|
if (script.is_valid()) {
|
||||||
|
@ -3004,8 +3007,12 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb
|
||||||
if (ste) {
|
if (ste) {
|
||||||
ste->goto_line_selection(line_number - 1, begin, end);
|
ste->goto_line_selection(line_number - 1, begin, end);
|
||||||
}
|
}
|
||||||
} else { //if file is not valid script, load as text file
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the file is not a valid resource/script, load it as a text file.
|
||||||
Error err;
|
Error err;
|
||||||
Ref<TextFile> text_file = _load_text_file(fpath, &err);
|
Ref<TextFile> text_file = _load_text_file(fpath, &err);
|
||||||
if (text_file.is_valid()) {
|
if (text_file.is_valid()) {
|
||||||
|
@ -3016,8 +3023,6 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb
|
||||||
te->goto_line_selection(line_number - 1, begin, end);
|
te->goto_line_selection(line_number - 1, begin, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEditor::_start_find_in_files(bool with_replace) {
|
void ScriptEditor::_start_find_in_files(bool with_replace) {
|
||||||
|
|
Loading…
Reference in a new issue