From 7c16b7e353e2e3504b5c2fe675046a6d81425634 Mon Sep 17 00:00:00 2001 From: Andrej Kacian Date: Thu, 30 Mar 2017 21:12:13 +0200 Subject: [PATCH] Make sure outgoing messages have a trailing newline. This fixes a corner case where if the last line of a message is a quote, its last character doesn't get displayed when viewing the copy in outbox. --- src/compose.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/compose.c b/src/compose.c index b7a7f7648..4e9386236 100644 --- a/src/compose.c +++ b/src/compose.c @@ -5611,7 +5611,7 @@ error: static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gboolean attach_parts) { GtkTextBuffer *buffer; - GtkTextIter start, end; + GtkTextIter start, end, tmp; gchar *chars, *tmp_enc_file, *content; gchar *buf, *msg; const gchar *out_codeset; @@ -5643,10 +5643,20 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool mimemsg->data.mem = compose_get_header(compose); /* Create text part MimeInfo */ - /* get all composed text */ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(compose->text)); - gtk_text_buffer_get_start_iter(buffer, &start); gtk_text_buffer_get_end_iter(buffer, &end); + tmp = end; + + /* We make sure that there is a newline at the end. */ + if (gtk_text_iter_backward_char(&tmp)) { + chars = gtk_text_buffer_get_text(buffer, &tmp, &end, FALSE); + if (*chars != '\n') { + gtk_text_buffer_insert(buffer, &end, "\n", 1); + } + } + + /* get all composed text */ + gtk_text_buffer_get_start_iter(buffer, &start); chars = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); out_codeset = conv_get_charset_str(compose->out_encoding);