From 58112ffbdcf1affb62961694cf57eab904c1d7f8 Mon Sep 17 00:00:00 2001 From: Tomas Popela Date: Thu, 19 Jun 2014 15:11:38 +0200 Subject: EHTMLEditorView - When quoting the elements correctly skip the selection markers --- e-util/e-html-editor-view.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c index ba10b1bc13..25b9bee34e 100644 --- a/e-util/e-html-editor-view.c +++ b/e-util/e-html-editor-view.c @@ -3405,6 +3405,29 @@ insert_quote_symbols_before_node (WebKitDOMDocument *document, g_free (quotation); } +static gboolean +element_is_selection_marker (WebKitDOMElement *element) +{ + gboolean is_marker = FALSE; + + is_marker = + element_has_id (element, "-x-evo-selection-start-marker") || + element_has_id (element, "-x-evo-selection-end-marker"); + + return is_marker; +} + +static gboolean +check_if_suppress_next_node (WebKitDOMNode *node) +{ + if (node && WEBKIT_DOM_IS_ELEMENT (node)) + if (element_is_selection_marker (WEBKIT_DOM_ELEMENT (node))) + if (!webkit_dom_node_get_previous_sibling (node)) + return FALSE; + + return TRUE; +} + static void quote_plain_text_recursive (WebKitDOMDocument *document, WebKitDOMNode *node, @@ -3459,10 +3482,12 @@ quote_plain_text_recursive (WebKitDOMDocument *document, goto next_node; } - if (element_has_id (WEBKIT_DOM_ELEMENT (node), "-x-evo-selection-start-marker") || - element_has_id (WEBKIT_DOM_ELEMENT (node), "-x-evo-selection-end-marker")) { + if (element_is_selection_marker (WEBKIT_DOM_ELEMENT (node))) { move_next = TRUE; - suppress_next = TRUE; + /* If there is collapsed selection in the beginning of line + * we cannot suppress first text that is after the end of + * selection */ + suppress_next = check_if_suppress_next_node (prev_sibling); goto next_node; } -- cgit v1.2.3