From 66d6478e8258a630742048496ea873835fe2839f Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Mon, 10 Aug 2020 14:15:08 +0100 Subject: [PATCH] elm_code: Selection start (with keyboard) fix. When starting a selection we were jumping two characters. This change resolves that. --- src/lib/elementary/elm_code_widget.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c index 9e6d37c..59298a0 100644 --- a/src/lib/elementary/elm_code_widget.c +++ b/src/lib/elementary/elm_code_widget.c @@ -1811,17 +1811,6 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED, _elm_code_widget_selection_type_set(widget, ELM_CODE_WIDGET_SELECTION_KEYBOARD); _elm_code_widget_selection_in_progress_set(widget, EINA_TRUE); - - if (pd->selection && pd->selection->start_line == pd->selection->end_line) - { - if ((pd->selection->end_col == pd->selection->start_col && !backwards) || - (pd->selection->end_col > pd->selection->start_col)) - elm_code_widget_cursor_position_set(widget, pd->selection->end_line, pd->selection->end_col+1); - } - else if (pd->selection && pd->selection->end_line > pd->selection->start_line) - { - elm_code_widget_cursor_position_set(widget, pd->selection->end_line, pd->selection->end_col+1); - } } else elm_code_widget_selection_clear(widget); @@ -1853,6 +1842,20 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED, elm_code_widget_selection_end(widget, pd->cursor_line, pd->cursor_col - (adjust?1:0)); _elm_code_widget_selection_in_progress_set(widget, EINA_FALSE); + + if (pd->selection) + { + if (pd->selection->end_line < pd->selection->start_line) + { + elm_code_widget_cursor_position_set(widget, pd->selection->end_line, pd->selection->end_col); + } + else if ((pd->selection->end_col == pd->selection->start_col && !backwards) || + (pd->selection->end_col > pd->selection->start_col) || + (pd->selection->end_line > pd->selection->start_line)) + { + elm_code_widget_cursor_position_set(widget, pd->selection->end_line, pd->selection->end_col+1); + } + } } } -- 2.7.4