[editor] Fix crash when deleting selections
If the selection ended in the carriage return the editor could craash. @fix
This commit is contained in:
parent
dbbcff2a3d
commit
9c9b92cada
|
@ -1,3 +1,7 @@
|
|||
2016-02-21 ajwillia.ms (Andy Williams)
|
||||
|
||||
* Fix crash when deleting a selection ending in newline
|
||||
|
||||
2016-02-11 ajwillia.ms (Andy Williams)
|
||||
|
||||
* Add a filename filter to the filepanel
|
||||
|
|
1
NEWS
1
NEWS
|
@ -13,6 +13,7 @@ Bug fixes:
|
|||
|
||||
* Focus input popups when they appear
|
||||
* Support fish and other non-bash shells for build & test
|
||||
* Fix crash when deleting a selection ending with newline
|
||||
|
||||
|
||||
=======
|
||||
|
|
|
@ -193,11 +193,20 @@ _elm_code_widget_selection_delete_multi(Elm_Code_Widget *widget, Elm_Code_Widget
|
|||
last = elm_code_line_text_get(line, &last_length);
|
||||
end = elm_code_widget_line_text_position_for_column_get(widget, line, selection->end_col);
|
||||
|
||||
length = start + last_length - (end + 1);
|
||||
content = malloc(sizeof(char) * length);
|
||||
strncpy(content, first, start);
|
||||
strncpy(content + start, last + end + 1,
|
||||
last_length - (end + 1));
|
||||
if (last_length == end)
|
||||
{
|
||||
length = start + last_length - end;
|
||||
content = malloc(sizeof(char) * length);
|
||||
strncpy(content, first, start);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = start + last_length - (end + 1);
|
||||
content = malloc(sizeof(char) * length);
|
||||
strncpy(content, first, start);
|
||||
|
||||
strncpy(content + start, last + end + 1, last_length - (end + 1));
|
||||
}
|
||||
|
||||
for (i = line->number; i > selection->start_line; i--)
|
||||
elm_code_file_line_remove(pd->code->file, i);
|
||||
|
|
Loading…
Reference in New Issue