diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-01 13:49:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-01 13:49:06 +0200 |
commit | 867f38a6263d40acb48fc4c9ebf038800dc63603 (patch) | |
tree | de06c263414fe45aae7b7cfb6f7fbf4580b9a08a /scene/gui/text_edit.cpp | |
parent | ab9c14cca63757ff47dfc6c38b35baf2a32a51ac (diff) | |
parent | 532a7ba06a0233879bbce61b2b268291e811df50 (diff) |
Merge pull request #29572 from qarmin/fix_text_edit_select
Fix TextEdit Select crash
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r-- | scene/gui/text_edit.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index f9bdce5fef..a6e3d644f6 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4817,14 +4817,18 @@ void TextEdit::deselect() { void TextEdit::select(int p_from_line, int p_from_column, int p_to_line, int p_to_column) { - if (p_from_line >= text.size()) + if (p_from_line < 0) + p_from_line = 0; + else if (p_from_line >= text.size()) p_from_line = text.size() - 1; if (p_from_column >= text[p_from_line].length()) p_from_column = text[p_from_line].length(); if (p_from_column < 0) p_from_column = 0; - if (p_to_line >= text.size()) + if (p_to_line < 0) + p_to_line = 0; + else if (p_to_line >= text.size()) p_to_line = text.size() - 1; if (p_to_column >= text[p_to_line].length()) p_to_column = text[p_to_line].length(); |