forked from enlightenment/efl
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
This commit is contained in:
parent
c9a89158db
commit
0f21b1f7aa
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue