From 6f7e23e6457fc899a060da453f37620897c1ba89 Mon Sep 17 00:00:00 2001 From: Tomas Popela Date: Tue, 15 Jul 2014 11:53:37 +0200 Subject: EHTMLEditorView - Replace the Tab characters in the text nodes just when generating the plain text version of the message --- e-util/e-html-editor-view.c | 52 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c index 3f4f1a2b8b..8b805b8b37 100644 --- a/e-util/e-html-editor-view.c +++ b/e-util/e-html-editor-view.c @@ -5184,33 +5184,35 @@ process_elements (EHTMLEditorView *view, gint char_count = 0; content = webkit_dom_node_get_text_content (child); - /* Replace tabs with 8 whitespaces, otherwise they got - * replaced by single whitespace */ - if (strstr (content, "\x9")) { - if (buffer->str && *buffer->str) { - gchar *start_of_line = g_strrstr_len ( - buffer->str, -1, "\n") + 1; - - if (start_of_line && *start_of_line) - char_count = strlen (start_of_line); - } else - char_count = 0; + if (!changing_mode && to_plain_text) { + /* Replace tabs with 8 whitespaces, otherwise they got + * replaced by single whitespace */ + if (strstr (content, "\x9")) { + if (buffer->str && *buffer->str) { + gchar *start_of_line = g_strrstr_len ( + buffer->str, -1, "\n") + 1; - regex = g_regex_new ("\x9", 0, 0, NULL); - tmp = g_regex_replace_eval ( - regex, - content, - -1, - 0, - 0, - (GRegexEvalCallback) replace_to_whitespaces, - GINT_TO_POINTER (char_count), - NULL); + if (start_of_line && *start_of_line) + char_count = strlen (start_of_line); + } else + char_count = 0; - g_string_append (buffer, tmp); - g_free (tmp); - content = webkit_dom_node_get_text_content (child); - g_regex_unref (regex); + regex = g_regex_new ("\x9", 0, 0, NULL); + tmp = g_regex_replace_eval ( + regex, + content, + -1, + 0, + 0, + (GRegexEvalCallback) replace_to_whitespaces, + GINT_TO_POINTER (char_count), + NULL); + + g_string_append (buffer, tmp); + g_free (tmp); + content = webkit_dom_node_get_text_content (child); + g_regex_unref (regex); + } } if (strstr (content, UNICODE_ZERO_WIDTH_SPACE)) { -- cgit v1.2.3