diff options
author | Alastair Poole <netstar@gmail.com> | 2018-08-17 11:37:59 +0000 |
---|---|---|
committer | Stefan Schmidt <s.schmidt@samsung.com> | 2018-08-17 21:44:17 +0200 |
commit | 0f21b1f7aaac18ba2ed3d10a6ff73f2db409c3bd (patch) | |
tree | 9d1c3a833ad58e91c5e297d1f98c15ec6fe870d4 | |
parent | c9a89158db020e69b1b74e86ceca0db2d6812c76 (diff) | |
download | efl-0f21b1f7aaac18ba2ed3d10a6ff73f2db409c3bd.tar.gz |
elm_code: fix crash on backspace and selection delete.
FIx backspace issue and also issue involving the cursor
position and deleting/cutting/backspace of selected text.
Now that we properly move the cursor around when making a
selection, it's important that we place the cursor in a
valid position in the widget following the removal of text.
Previously the cursor always remained in a "safe" position
however now it's crucial to update this position when
necessary.
@fix T7259
Differential Revision: https://phab.enlightenment.org/D6835
-rw-r--r-- | src/lib/elementary/elm_code_widget.c | 15 | ||||
-rw-r--r-- | src/lib/elementary/elm_code_widget_selection.c | 8 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c index 600a9b786c..1c315f047d 100644 --- a/src/lib/elementary/elm_code_widget.c +++ b/src/lib/elementary/elm_code_widget.c @@ -1558,7 +1558,7 @@ _elm_code_widget_backspaceline(Elm_Code_Widget *widget, Eina_Bool nextline) { Elm_Code *code; Elm_Code_Line *line, *oldline; - unsigned int row, col, oldlength, position; + unsigned int row, col, oldlength, position = 0; code = elm_obj_code_widget_code_get(widget); elm_obj_code_widget_cursor_position_get(widget, &row, &col); @@ -1584,8 +1584,19 @@ _elm_code_widget_backspaceline(Elm_Code_Widget *widget, Eina_Bool nextline) elm_code_line_merge_up(line); } + elm_code_widget_selection_clear(widget); -// TODO construct and pass a change object + + line = elm_code_file_line_get(code->file, row - 1); + if (line) + { + if (position) + elm_code_widget_cursor_position_set(widget, row - 1, position); + else + elm_code_widget_cursor_position_set(widget, row - 1, line->length + 1); + } + + // TODO construct and pass a change object efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_CHANGED_USER, NULL); } diff --git a/src/lib/elementary/elm_code_widget_selection.c b/src/lib/elementary/elm_code_widget_selection.c index 834c025e94..cf5f355009 100644 --- a/src/lib/elementary/elm_code_widget_selection.c +++ b/src/lib/elementary/elm_code_widget_selection.c @@ -251,26 +251,32 @@ _elm_code_widget_selection_delete_do(Evas_Object *widget, Eina_Bool undo) { Elm_Code_Widget_Data *pd; Elm_Code_Widget_Selection_Data *selection; + unsigned int row, col; pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); if (!pd->selection) return; + if (undo) _elm_code_widget_change_selection_add(widget); selection = elm_code_widget_selection_normalized_get(widget); + + row = selection->start_line; + col = selection->start_col; + if (selection->start_line == selection->end_line) _elm_code_widget_selection_delete_single(widget, pd); else _elm_code_widget_selection_delete_multi(widget, pd); - elm_code_widget_cursor_position_set(widget, selection->start_line, selection->start_col); free(pd->selection); pd->selection = NULL; free(selection); efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_SELECTION_CLEARED, widget); + elm_code_widget_cursor_position_set(widget, row, col); } EAPI void |