[evolution/wip/webkit-composer] EEditorWidget: Try to remove UNICODE_ZERO_WIDTH_SPACE just when there is 1+ characters



commit 9418dc0410c41dd14cd612edf1bf08959ed5cd61
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Jan 30 11:50:03 2014 +0100

    EEditorWidget: Try to remove UNICODE_ZERO_WIDTH_SPACE just when there is 1+ characters

 e-util/e-editor-widget.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index 2394ead..e328dae 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -315,11 +315,13 @@ body_input_event_cb (WebKitDOMElement *element,
        node = webkit_dom_range_get_end_container (range, NULL);
        if (WEBKIT_DOM_IS_TEXT (node)) {
                gchar *text = webkit_dom_node_get_text_content (node);
-               if (strstr (text, UNICODE_ZERO_WIDTH_SPACE)) {
+               glong length = g_utf8_strlen (text, -1);
+               /* We have to preserve empty paragraphs with just UNICODE_ZERO_WIDTH_SPACE
+                * character as when we will remove it it will collapse */
+               if (length > 1 && strstr (text, UNICODE_ZERO_WIDTH_SPACE)) {
                        WebKitDOMDocument *document;
                        WebKitDOMDOMWindow *window;
                        WebKitDOMDOMSelection *selection;
-
                        GString *res = e_str_replace_string (text, UNICODE_ZERO_WIDTH_SPACE, "");
 
                        webkit_dom_node_set_text_content (node, res->str, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]