Skip to content

Commit

Permalink
Merge pull request godotengine#88479 from passivestar/lineedit-delete…
Browse files Browse the repository at this point in the history
…-with-selection

Fix `LineEdit` delete all the way to the left/right when something is selected
  • Loading branch information
akien-mga committed Feb 19, 2024
2 parents 5936844 + c2a4a0d commit a92921a
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions scene/gui/line_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,23 @@ 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);
_text_changed();
return;
}

if (selection.enabled) {
selection_delete();
return;
}

if (p_word) {
int cc = caret_column;

Expand All @@ -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);
Expand Down

0 comments on commit a92921a

Please sign in to comment.