[evolution] Bug 773164 - copy pasting paragraphs and then undoing - redoing is broken
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 773164 - copy pasting paragraphs and then undoing - redoing is broken
- Date: Wed, 19 Oct 2016 10:36:30 +0000 (UTC)
commit d5aba1905c9f259672468c7fbc30df93eee4f751
Author: Tomas Popela <tpopela redhat com>
Date: Wed Oct 19 12:32:15 2016 +0200
Bug 773164 - copy pasting paragraphs and then undoing - redoing is broken
The code for saving the undo/redo history for cut was not called for the
Ctrl-x shortcut. Also remove a WebKit's BR element if presented
(otherwise an extra new line would be presented).
src/e-util/test-html-editor-units-bugs.c | 35 ++++++++++++++++++++
src/modules/webkit-editor/e-webkit-editor.c | 6 ++-
.../web-extension/e-editor-dom-functions.c | 18 ++++++++++
3 files changed, 57 insertions(+), 2 deletions(-)
---
diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c
index 34717e4..700508f 100644
--- a/src/e-util/test-html-editor-units-bugs.c
+++ b/src/e-util/test-html-editor-units-bugs.c
@@ -744,6 +744,40 @@ test_bug_772918 (TestFixture *fixture)
g_test_fail ();
}
+static void
+test_bug_773164 (TestFixture *fixture)
+{
+ test_utils_set_clipboard_text ("This is paragraph 1\n\nThis is paragraph 2\n\nThis is a longer
paragraph 3", FALSE);
+
+ if (!test_utils_run_simple_test (fixture,
+ "mode:plain\n"
+ "undo:save\n"
+ "action:paste\n"
+ "undo:undo\n"
+ "undo:test\n"
+ "undo:redo\n"
+ "seq:huuuue\n" /* Go to the end of the first line */
+ "seq:Sdds\n"
+ "action:cut\n"
+ "seq:dde\n" /* Go to the end of the last line */
+ "action:paste\n"
+ "undo:undo:5\n"
+ "undo:test\n"
+ "undo:redo:5\n",
+ HTML_PREFIX "<div style=\"width: 71ch;\">This is paragraph 1</div>"
+ "<div style=\"width: 71ch;\"><br></div>"
+ "<div style=\"width: 71ch;\">This is a longer paragraph 3</div>"
+ "<div style=\"width: 71ch;\"><br></div>"
+ "<div style=\"width: 71ch;\">This is paragraph 2</div>"
+ HTML_SUFFIX,
+ "This is paragraph 1\n"
+ "\n"
+ "This is a longer paragraph 3\n"
+ "\n"
+ "This is paragraph 2"))
+ g_test_fail ();
+}
+
void
test_add_html_editor_bug_tests (void)
{
@@ -762,4 +796,5 @@ test_add_html_editor_bug_tests (void)
test_utils_add_test ("/bug/772171", test_bug_772171);
test_utils_add_test ("/bug/772513", test_bug_772513);
test_utils_add_test ("/bug/772918", test_bug_772918);
+ test_utils_add_test ("/bug/773164", test_bug_773164);
}
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 0a3afde..1329842 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -5819,8 +5819,10 @@ webkit_editor_key_press_event (GtkWidget *widget,
return TRUE;
}
- if (((event)->state & GDK_SHIFT_MASK) &&
- ((event)->keyval == GDK_KEY_Delete)) {
+ if ((((event)->state & GDK_SHIFT_MASK) &&
+ ((event)->keyval == GDK_KEY_Delete)) ||
+ (((event)->state & GDK_CONTROL_MASK) &&
+ ((event)->keyval == GDK_KEY_x))) {
webkit_editor_cut (E_CONTENT_EDITOR (wk_editor));
return TRUE;
}
diff --git a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 869d0b1..9bfcbdc 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -8655,6 +8655,22 @@ pasting_quoted_content (const gchar *content)
strstr (content, "\"-x-evo-");
}
+static void
+remove_apple_interchange_newline_elements (WebKitDOMDocument *document)
+{
+ gint ii;
+ WebKitDOMHTMLCollection *collection = NULL;
+
+ collection = webkit_dom_document_get_elements_by_class_name_as_html_collection (
+ document, "Apple-interchange-newline");
+ for (ii = webkit_dom_html_collection_get_length (collection); ii--;) {
+ WebKitDOMNode *node = webkit_dom_html_collection_item (collection, ii);
+
+ remove_node (node);
+ }
+ g_clear_object (&collection);
+}
+
/*
* e_editor_dom_insert_html:
* @selection: an #EEditorSelection
@@ -8806,6 +8822,8 @@ e_editor_dom_insert_html (EEditorPage *editor_page,
} else
e_editor_dom_convert_and_insert_html_into_selection (editor_page, html_text, TRUE);
+ remove_apple_interchange_newline_elements (document);
+
if (ev) {
e_editor_dom_selection_get_coordinates (editor_page,
&ev->after.start.x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]