Skip to content

Commit

Permalink
Merge pull request #51732 from codecat/fix-caret-selection-3.x
Browse files Browse the repository at this point in the history
Move cursor to edge of selection when moving caret left/right
  • Loading branch information
akien-mga authored Aug 18, 2021
2 parents f87c6a3 + 6bf6d18 commit a67eaa6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scene/gui/text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2817,7 +2817,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {

_reset_caret_blink_timer();

// Save here for insert mode, just in case it is cleared in the following section.
// Save here for insert mode as well as arrow navigation, just in case it is cleared in the following section.
bool had_selection = selection.active;

// Stuff to do when selection is active.
Expand Down Expand Up @@ -3173,6 +3173,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
case KEY_LEFT: {
if (k->get_shift()) {
_pre_shift_selection();
} else if (had_selection && !k->get_command() && !k->get_alt()) {
cursor_set_line(selection.from_line);
cursor_set_column(selection.from_column);
deselect();
break;
#ifdef APPLE_STYLE_KEYS
} else {
#else
Expand Down Expand Up @@ -3250,6 +3255,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
case KEY_RIGHT: {
if (k->get_shift()) {
_pre_shift_selection();
} else if (had_selection && !k->get_command() && !k->get_alt()) {
cursor_set_line(selection.to_line);
cursor_set_column(selection.to_column);
deselect();
break;
#ifdef APPLE_STYLE_KEYS
} else {
#else
Expand Down

0 comments on commit a67eaa6

Please sign in to comment.