From 31ba932e3bf7b3ad7ab6ef559fbdb3656d7afe86 Mon Sep 17 00:00:00 2001 From: Marcelo Fernandez Date: Sun, 17 Sep 2017 17:07:42 -0300 Subject: [PATCH] Fix crash when using key+u on a line with only a # --- scene/gui/text_edit.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index db6d257640a..2ca4c813190 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2804,8 +2804,12 @@ void TextEdit::_gui_input(const Ref &p_gui_input) { _remove_text(i, 0, i, 1); } } else { - if (get_line(cursor.line).begins_with("#")) + if (get_line(cursor.line).begins_with("#")) { _remove_text(cursor.line, 0, cursor.line, 1); + if (cursor.column >= get_line(cursor.line).length()) { + cursor.column = MAX(0, get_line(cursor.line).length() - 1); + } + } } update(); }