elm_code: Selection start (with keyboard) fix.
authorAlastair Poole <netstar@gmail.com>
Mon, 10 Aug 2020 13:15:08 +0000 (14:15 +0100)
committerJongmin Lee <jm105.lee@samsung.com>
Mon, 10 Aug 2020 21:28:18 +0000 (06:28 +0900)
When starting a selection we were jumping two characters. This
change resolves that.

src/lib/elementary/elm_code_widget.c

index 9e6d37c..59298a0 100644 (file)
@@ -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);
+                    }
+               }
           }
      }