[whitespace] Fix indentation after newline when splitting.
Make sure that whitespace to the right is ignored
This commit is contained in:
parent
d6b9a3f82c
commit
e6a49ec22f
|
@ -210,6 +210,19 @@ elm_code_line_text_remove(Elm_Code_Line *line, unsigned int position, int length
|
|||
elm_code_callback_fire(file->parent, &ELM_CODE_EVENT_LINE_LOAD_DONE, line);
|
||||
}
|
||||
|
||||
EAPI void elm_code_line_text_leading_whitespace_strip(Elm_Code_Line *line)
|
||||
{
|
||||
unsigned int length, leading;
|
||||
const char *content;
|
||||
|
||||
content = elm_code_line_text_get(line, &length);
|
||||
leading = elm_code_text_leading_whitespace_length(content, length);
|
||||
if (leading == 0)
|
||||
return;
|
||||
|
||||
elm_code_line_text_remove(line, 0, leading);
|
||||
}
|
||||
|
||||
EAPI void elm_code_line_text_trailing_whitespace_strip(Elm_Code_Line *line)
|
||||
{
|
||||
unsigned int length, trailing;
|
||||
|
@ -220,8 +233,7 @@ EAPI void elm_code_line_text_trailing_whitespace_strip(Elm_Code_Line *line)
|
|||
if (trailing == 0)
|
||||
return;
|
||||
|
||||
length -= trailing;;
|
||||
elm_code_line_text_set(line, content, length);
|
||||
elm_code_line_text_remove(line, length - trailing, trailing);
|
||||
}
|
||||
|
||||
/* generic text functions */
|
||||
|
|
|
@ -36,6 +36,8 @@ EAPI void elm_code_line_text_insert(Elm_Code_Line *line, unsigned int position,
|
|||
|
||||
EAPI void elm_code_line_text_remove(Elm_Code_Line *line, unsigned int position, int length);
|
||||
|
||||
EAPI void elm_code_line_text_leading_whitespace_strip(Elm_Code_Line *line);
|
||||
|
||||
EAPI void elm_code_line_text_trailing_whitespace_strip(Elm_Code_Line *line);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1030,6 +1030,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_leading_whitespace_strip(line);
|
||||
elm_code_line_text_insert(line, 0, oldtext, leading);
|
||||
free(oldtext);
|
||||
|
||||
|
|
Loading…
Reference in New Issue