From 2c0d0c14734964c67669a3ee0c4f1cbad32a1e4f Mon Sep 17 00:00:00 2001 From: passivestar <60579014+passivestar@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:11:48 +0400 Subject: [PATCH] Fix LineEdit behavior for deleting all the way to the left/right --- scene/gui/line_edit.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index a6109a39257..37212a34ad3 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -140,7 +140,9 @@ void LineEdit::_backspace(bool p_word, bool p_all_to_left) { if (p_all_to_left) { deselect(); - text = text.substr(0, caret_column); + text = text.substr(caret_column); + _shape(); + set_caret_column(0); _text_changed(); return; } @@ -176,9 +178,8 @@ void LineEdit::_delete(bool p_word, bool p_all_to_right) { if (p_all_to_right) { deselect(); - text = text.substr(caret_column, text.length() - caret_column); + text = text.substr(0, caret_column); _shape(); - set_caret_column(0); _text_changed(); return; }