From 22c15083afdf29e741d7b5fed966d2f09ca994aa Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Sat, 11 Jan 2020 17:57:36 +0000 Subject: [PATCH] Fix empty LineEdit crash on ctrl+backspace --- scene/gui/line_edit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 5351b6cadcf..a6cd9a06655 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1193,7 +1193,7 @@ void LineEdit::delete_char() { set_cursor_position(get_cursor_position() - 1); 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(); @@ -1224,7 +1224,7 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) { } 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) {