diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-19 10:43:58 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-19 10:43:58 +0100 |
commit | a92921ae49290370b43f2302853c7af19d22e8c0 (patch) | |
tree | 1470f412c89d596e223039a87327945d529bfad1 | |
parent | 59368441e31c92b4dbaa51c075ca55ce8d4b7b9b (diff) | |
parent | c2a4a0d4cb4e82386a632db51bb9d122274b5e30 (diff) | |
download | redot-engine-a92921ae49290370b43f2302853c7af19d22e8c0.tar.gz |
Merge pull request #88479 from passivestar/lineedit-delete-with-selection
Fix `LineEdit` delete all the way to the left/right when something is selected
-rw-r--r-- | scene/gui/line_edit.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 37212a34ad..7aa4a136d9 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -138,8 +138,16 @@ void LineEdit::_backspace(bool p_word, bool p_all_to_left) { return; } + if (selection.enabled) { + selection_delete(); + return; + } + + if (caret_column == 0) { + return; // Nothing to do. + } + if (p_all_to_left) { - deselect(); text = text.substr(caret_column); _shape(); set_caret_column(0); @@ -147,11 +155,6 @@ void LineEdit::_backspace(bool p_word, bool p_all_to_left) { return; } - if (selection.enabled) { - selection_delete(); - return; - } - if (p_word) { int cc = caret_column; @@ -176,25 +179,22 @@ void LineEdit::_delete(bool p_word, bool p_all_to_right) { return; } - if (p_all_to_right) { - deselect(); - text = text.substr(0, caret_column); - _shape(); - _text_changed(); - return; - } - if (selection.enabled) { selection_delete(); return; } - int text_len = text.length(); - - if (caret_column == text_len) { + if (caret_column == text.length()) { return; // Nothing to do. } + if (p_all_to_right) { + text = text.substr(0, caret_column); + _shape(); + _text_changed(); + return; + } + if (p_word) { int cc = caret_column; PackedInt32Array words = TS->shaped_text_get_word_breaks(text_rid); |