I think it's a bug. I didn't notice it before as I usually use
addons plugin with "Strip trailing blank lines" option checked. Patch
attached, also modified to use utils_get_eol_char().
Best regards,
Eugene.
diff --git a/src/editor.c b/src/editor.c
index a012f7d..7e01edc 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -4609,26 +4609,12 @@ void editor_strip_trailing_spaces(GeanyEditor *editor)
void editor_ensure_final_newline(GeanyEditor *editor)
{
gint max_lines = sci_get_line_count(editor->sci);
- gboolean append_newline = (max_lines == 1);
gint end_document = sci_get_position_from_line(editor->sci, max_lines);
- if (max_lines > 1)
+ if (max_lines > 1 && end_document > sci_get_position_from_line(editor->sci, max_lines - 1))
{
- append_newline = end_document > sci_get_position_from_line(editor->sci, max_lines - 1);
- }
- if (append_newline)
- {
- const gchar *eol = "\n";
- switch (sci_get_eol_mode(editor->sci))
- {
- case SC_EOL_CRLF:
- eol = "\r\n";
- break;
- case SC_EOL_CR:
- eol = "\r";
- break;
- }
- sci_insert_text(editor->sci, end_document, eol);
+ sci_insert_text(editor->sci, end_document,
+ utils_get_eol_char(sci_get_eol_mode(editor->sci)));
}
}
_______________________________________________
Geany-devel mailing list
Geany-devel@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel