diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-08-12 10:07:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 10:07:12 +0200 |
commit | fba0c8e2e2275d34d75dd0b3d524383fd99e1dfd (patch) | |
tree | 2b8c3a32f6f467a7862d36b35090f36a46a1b01a | |
parent | 22ccb74aff00f7b073e3eb4f0c26fec858ef1884 (diff) | |
parent | ed4c3eb7b350f3a4597f301a45139b31269bf95e (diff) |
Merge pull request #51502 from codecat/fix-caret-selection
Move cursor to edge of selection when moving caret left/right
-rw-r--r-- | scene/gui/text_edit.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 3c6034f938..985abf8e55 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1584,6 +1584,12 @@ void TextEdit::_move_cursor_left(bool p_select, bool p_move_by_word) { // Handle selection if (p_select) { _pre_shift_selection(); + } else if (selection.active && !p_move_by_word) { + // If a selection is active, move cursor to start of selection + cursor_set_line(selection.from_line); + cursor_set_column(selection.from_column); + deselect(); + return; } else { deselect(); } @@ -1629,6 +1635,12 @@ void TextEdit::_move_cursor_right(bool p_select, bool p_move_by_word) { // Handle selection if (p_select) { _pre_shift_selection(); + } else if (selection.active && !p_move_by_word) { + // If a selection is active, move cursor to end of selection + cursor_set_line(selection.to_line); + cursor_set_column(selection.to_column); + deselect(); + return; } else { deselect(); } |