diff --git a/ChangeLog b/ChangeLog index 743ab71c..b3bbb251 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ Add option to insert line numbers (closes #3197150). Cleanup. Use the full filename and add the extension of the export format. + Fix off-by-one bug which hidden the last empty line of a document. 2011-03-05 Colomban Wendling diff --git a/plugins/export.c b/plugins/export.c index b56cd95d..bd5429bc 100644 --- a/plugins/export.c +++ b/plugins/export.c @@ -392,7 +392,7 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, /* read the document and write the LaTeX code */ body = g_string_new(""); doc_len = sci_get_length(sci); - for (i = 0; i < doc_len; i++) + for (i = 0; i <= doc_len; i++) { style = sci_get_style_at(sci, i); c = sci_get_char_at(sci, i); @@ -421,9 +421,11 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, g_string_append(body, "}\n"); block_open = FALSE; } - g_string_append_printf(body, "\\style%s{", get_tex_style(style)); - - block_open = TRUE; + if (i < doc_len) + { + g_string_append_printf(body, "\\style%s{", get_tex_style(style)); + block_open = TRUE; + } } /* escape the current character if necessary else just add it */ switch (c) @@ -632,7 +634,7 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, /* read the document and write the HTML body */ body = g_string_new(""); doc_len = sci_get_length(sci); - for (i = 0; i < doc_len; i++) + for (i = 0; i <= doc_len; i++) { style = sci_get_style_at(sci, i); c = sci_get_char_at(sci, i); @@ -661,9 +663,11 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, { g_string_append(body, ""); } - g_string_append_printf(body, "", style); - - span_open = TRUE; + if (i < doc_len) + { + g_string_append_printf(body, "", style); + span_open = TRUE; + } } /* escape the current character if necessary else just add it */ switch (c)