Skip to content

Commit

Permalink
Merge pull request #81410 from bitsawer/fix_shader_include_reload
Browse files Browse the repository at this point in the history
Fix shader text editor include file reloading
  • Loading branch information
akien-mga committed Sep 7, 2023
2 parents 5641d44 + d50595c commit 074931a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions editor/plugins/text_shader_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,22 @@ void ShaderTextEditor::set_edited_code(const String &p_code) {
}

void ShaderTextEditor::reload_text() {
ERR_FAIL_COND(shader.is_null());
ERR_FAIL_COND(shader.is_null() && shader_inc.is_null());

String code;
if (shader.is_valid()) {
code = shader->get_code();
} else {
code = shader_inc->get_code();
}

CodeEdit *te = get_text_editor();
int column = te->get_caret_column();
int row = te->get_caret_line();
int h = te->get_h_scroll();
int v = te->get_v_scroll();

te->set_text(shader->get_code());
te->set_text(code);
te->set_caret_line(row);
te->set_caret_column(column);
te->set_h_scroll(h);
Expand Down

0 comments on commit 074931a

Please sign in to comment.