From 6b7008b73beca0df5722cd4434dc4ac4ad7c99fe Mon Sep 17 00:00:00 2001 From: RedworkDE <10944644+RedworkDE@users.noreply.github.com> Date: Tue, 30 May 2023 20:19:08 +0200 Subject: [PATCH] Fix crash when selecting lines in text edit --- scene/gui/text_edit.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index aa6c4a1a4d7..039fa46bb0a 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -7161,7 +7161,9 @@ void TextEdit::_update_selection_mode_line() { if (line < carets[caret_idx].selection.selecting_line) { // Caret is above us. set_caret_line(line - 1, false, true, 0, caret_idx); - carets.write[caret_idx].selection.selecting_column = text[get_selection_line(caret_idx)].length(); + carets.write[caret_idx].selection.selecting_column = has_selection(caret_idx) + ? text[get_selection_line(caret_idx)].length() + : 0; } else { // Caret is below us. set_caret_line(line + 1, false, true, 0, caret_idx);