Merge pull request #35019 from Paulb23/issue_35016_line_edit_backspace_crash

Fix empty LineEdit crash on ctrl+backspace
This commit is contained in:
Rémi Verschelde 2020-01-11 20:06:38 +01:00 committed by GitHub
commit b563de702c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1193,7 +1193,7 @@ void LineEdit::delete_char() {
set_cursor_position(get_cursor_position() - 1); set_cursor_position(get_cursor_position() - 1);
if (align == ALIGN_CENTER || align == ALIGN_RIGHT) { if (align == ALIGN_CENTER || align == ALIGN_RIGHT) {
window_pos = CLAMP(window_pos - 1, 0, text.length() - 1); window_pos = CLAMP(window_pos - 1, 0, MAX(text.length() - 1, 0));
} }
_text_changed(); _text_changed();
@ -1224,7 +1224,7 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) {
} }
if (align == ALIGN_CENTER || align == ALIGN_RIGHT) { if (align == ALIGN_CENTER || align == ALIGN_RIGHT) {
window_pos = CLAMP(window_pos - (p_to_column - p_from_column), 0, text.length() - 1); window_pos = CLAMP(window_pos - (p_to_column - p_from_column), 0, MAX(text.length() - 1, 0));
} }
if (!text_changed_dirty) { if (!text_changed_dirty) {