[editor] Fix indenting of newlines
Changes in memory handling of line splits broke this in some cases (like tapping return twice).
This commit is contained in:
parent
af6297992e
commit
7e62826b59
|
@ -993,7 +993,7 @@ _elm_code_widget_newline(Elm_Code_Widget *widget)
|
|||
Elm_Code *code;
|
||||
Elm_Code_Line *line;
|
||||
unsigned int row, col, position, oldlen, leading;
|
||||
const char *oldtext;
|
||||
char *oldtext;
|
||||
|
||||
_elm_code_widget_delete_selection(widget);
|
||||
eo_do(widget,
|
||||
|
@ -1006,7 +1006,8 @@ _elm_code_widget_newline(Elm_Code_Widget *widget)
|
|||
row = elm_code_file_lines_get(code->file);
|
||||
line = elm_code_file_line_get(code->file, row);
|
||||
}
|
||||
oldtext = elm_code_line_text_get(line, &oldlen);
|
||||
oldtext = (char *) elm_code_line_text_get(line, &oldlen);
|
||||
oldtext = strndup(oldtext, oldlen);
|
||||
|
||||
position = elm_code_widget_line_text_position_for_column_get(widget, line, col);
|
||||
elm_code_line_split_at(line, position);
|
||||
|
@ -1014,6 +1015,7 @@ _elm_code_widget_newline(Elm_Code_Widget *widget)
|
|||
line = elm_code_file_line_get(code->file, row + 1);
|
||||
leading = elm_code_text_leading_whitespace_length(oldtext, oldlen);
|
||||
elm_code_line_text_insert(line, 0, oldtext, leading);
|
||||
free(oldtext);
|
||||
|
||||
eo_do(widget,
|
||||
elm_obj_code_widget_cursor_position_set(
|
||||
|
|
Loading…
Reference in New Issue