summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2020-08-10 14:15:08 +0100
committerAlastair Poole <netstar@gmail.com>2020-08-10 14:15:08 +0100
commitc26f56aef9391c9255f1e2beda8a81028240b6ca (patch)
tree811596b4740255ca5463f117a0165bd232e8cb7e
parent39f21df49385473a5743c0838a5da344603f6494 (diff)
elm_code: Selection start (with keyboard) fix.
When starting a selection we were jumping two characters. This change resolves that.
-rw-r--r--src/lib/elementary/elm_code_widget.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c
index 9e6d37cc95..59298a0462 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,
1811 1811
1812 _elm_code_widget_selection_type_set(widget, ELM_CODE_WIDGET_SELECTION_KEYBOARD); 1812 _elm_code_widget_selection_type_set(widget, ELM_CODE_WIDGET_SELECTION_KEYBOARD);
1813 _elm_code_widget_selection_in_progress_set(widget, EINA_TRUE); 1813 _elm_code_widget_selection_in_progress_set(widget, EINA_TRUE);
1814
1815 if (pd->selection && pd->selection->start_line == pd->selection->end_line)
1816 {
1817 if ((pd->selection->end_col == pd->selection->start_col && !backwards) ||
1818 (pd->selection->end_col > pd->selection->start_col))
1819 elm_code_widget_cursor_position_set(widget, pd->selection->end_line, pd->selection->end_col+1);
1820 }
1821 else if (pd->selection && pd->selection->end_line > pd->selection->start_line)
1822 {
1823 elm_code_widget_cursor_position_set(widget, pd->selection->end_line, pd->selection->end_col+1);
1824 }
1825 } 1814 }
1826 else 1815 else
1827 elm_code_widget_selection_clear(widget); 1816 elm_code_widget_selection_clear(widget);
@@ -1853,6 +1842,20 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED,
1853 1842
1854 elm_code_widget_selection_end(widget, pd->cursor_line, pd->cursor_col - (adjust?1:0)); 1843 elm_code_widget_selection_end(widget, pd->cursor_line, pd->cursor_col - (adjust?1:0));
1855 _elm_code_widget_selection_in_progress_set(widget, EINA_FALSE); 1844 _elm_code_widget_selection_in_progress_set(widget, EINA_FALSE);
1845
1846 if (pd->selection)
1847 {
1848 if (pd->selection->end_line < pd->selection->start_line)
1849 {
1850 elm_code_widget_cursor_position_set(widget, pd->selection->end_line, pd->selection->end_col);
1851 }
1852 else if ((pd->selection->end_col == pd->selection->start_col && !backwards) ||
1853 (pd->selection->end_col > pd->selection->start_col) ||
1854 (pd->selection->end_line > pd->selection->start_line))
1855 {
1856 elm_code_widget_cursor_position_set(widget, pd->selection->end_line, pd->selection->end_col+1);
1857 }
1858 }
1856 } 1859 }
1857 } 1860 }
1858 1861