[whitespace] Fix indentation after newline when splitting.

Make sure that whitespace to the right is ignored
This commit is contained in:
Andy Williams 2015-10-10 14:09:02 -07:00
parent b0771bdfc6
commit 193f17be2b
4 changed files with 18 additions and 2 deletions

1
NEWS
View File

@ -11,6 +11,7 @@ Bug fixes
* Correct selection so it works backwards as well
* Don't remove highlighting of lines when backspace/delete or newline are entered
* When opening unrecognised files and cancelling choice don't remember as opened
* Fix issue with whitespace indenting on newline when splitting at whitespace
=======

View File

@ -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 */

View File

@ -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);
/**

View File

@ -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);