Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LineEdit delete all the way to the left/right when something is selected #88479

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading