Resolves: RHEL-29169 (Composer: Cursor jumps to the starting line when "return" key is pressed at the end of the line)

This commit is contained in:
Milan Crha 2024-03-14 16:57:27 +01:00
parent 0200e6a382
commit 9fa05be175
2 changed files with 41 additions and 24 deletions

View File

@ -1,8 +1,7 @@
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 3568f6e..35de5c0 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
@@ -626,6 +626,20 @@ e_editor_dom_exec_command (EEditorPage *editor_page,
diff -up evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c.webkitgtk-2.40 evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
--- evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c.webkitgtk-2.40 2024-03-14 16:53:57.689790750 +0100
+++ evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c 2024-03-14 16:54:21.549102464 +0100
@@ -626,6 +626,20 @@ e_editor_dom_exec_command (EEditorPage *
e_editor_page_get_document (editor_page), cmd_str, FALSE, has_value ? value : "" );
}
@ -23,7 +22,7 @@ index 3568f6e..35de5c0 100644
static void
perform_spell_check (WebKitDOMDOMSelection *dom_selection,
WebKitDOMRange *start_range,
@@ -642,8 +656,7 @@ perform_spell_check (WebKitDOMDOMSelection *dom_selection,
@@ -642,8 +656,7 @@ perform_spell_check (WebKitDOMDOMSelecti
g_object_unref (actual);
webkit_dom_dom_selection_modify (
dom_selection, "move", "forward", "word");
@ -33,7 +32,7 @@ index 3568f6e..35de5c0 100644
}
g_clear_object (&actual);
}
@@ -1524,8 +1537,10 @@ e_editor_dom_check_magic_links (EEditorPage *editor_page,
@@ -1524,8 +1537,10 @@ e_editor_dom_check_magic_links (EEditorP
selection_end_marker = webkit_dom_document_get_element_by_id (
document, "-x-evo-selection-end-marker");
@ -46,7 +45,7 @@ index 3568f6e..35de5c0 100644
}
}
@@ -4120,7 +4134,7 @@ caret_is_on_the_line_beginning_html (WebKitDOMDocument *document)
@@ -4120,7 +4135,7 @@ caret_is_on_the_line_beginning_html (Web
dom_window = webkit_dom_document_get_default_view (document);
dom_selection = webkit_dom_dom_window_get_selection (dom_window);
@ -55,7 +54,7 @@ index 3568f6e..35de5c0 100644
webkit_dom_dom_selection_modify (dom_selection, "move", "left", "lineBoundary");
@@ -9388,7 +9402,7 @@ save_history_for_delete_or_backspace (EEditorPage *editor_page,
@@ -9388,7 +9403,7 @@ save_history_for_delete_or_backspace (EE
return;
}
@ -64,7 +63,7 @@ index 3568f6e..35de5c0 100644
/* Check if we can delete something */
if (webkit_dom_range_get_collapsed (range, NULL)) {
@@ -9503,7 +9517,7 @@ save_history_for_delete_or_backspace (EEditorPage *editor_page,
@@ -9503,7 +9518,7 @@ save_history_for_delete_or_backspace (EE
} else {
WebKitDOMRange *tmp_range = NULL, *actual_range = NULL;
@ -73,7 +72,7 @@ index 3568f6e..35de5c0 100644
webkit_dom_dom_selection_modify (
dom_selection, "move", delete_key ? "right" : "left", "character");
@@ -11348,7 +11362,7 @@ e_editor_dom_save_history_for_drag (EEditorPage *editor_page)
@@ -11348,7 +11363,7 @@ e_editor_dom_save_history_for_drag (EEdi
}
/* Obtain the dragged content. */
@ -82,7 +81,7 @@ index 3568f6e..35de5c0 100644
range_clone = webkit_dom_range_clone_range (range, NULL);
/* Create the history event for the content that will
@@ -11708,7 +11722,7 @@ e_editor_dom_get_current_range (EEditorPage *editor_page)
@@ -11708,7 +11723,7 @@ e_editor_dom_get_current_range (EEditorP
if (webkit_dom_dom_selection_get_range_count (dom_selection) < 1)
goto exit;
@ -91,7 +90,7 @@ index 3568f6e..35de5c0 100644
exit:
g_clear_object (&dom_selection);
g_clear_object (&dom_window);
@@ -13515,6 +13529,107 @@ e_editor_dom_is_selection_position_node (WebKitDOMNode *node)
@@ -13515,6 +13530,107 @@ e_editor_dom_is_selection_position_node
element_has_id (element, "-x-evo-selection-end-marker");
}
@ -199,7 +198,7 @@ index 3568f6e..35de5c0 100644
/*
* e_html_editor_selection_restore:
* @selection: an #EEditorSelection
@@ -13531,12 +13646,13 @@ e_editor_dom_selection_restore (EEditorPage *editor_page)
@@ -13531,12 +13647,13 @@ e_editor_dom_selection_restore (EEditorP
WebKitDOMDocument *document;
WebKitDOMElement *marker;
WebKitDOMNode *selection_start_marker, *selection_end_marker;
@ -215,7 +214,7 @@ index 3568f6e..35de5c0 100644
g_return_if_fail (E_IS_EDITOR_PAGE (editor_page));
@@ -13614,7 +13730,7 @@ e_editor_dom_selection_restore (EEditorPage *editor_page)
@@ -13614,7 +13731,7 @@ e_editor_dom_selection_restore (EEditorP
start_is_anchor = webkit_dom_element_has_attribute (marker, "data-anchor");
parent_start = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker));
@ -224,7 +223,7 @@ index 3568f6e..35de5c0 100644
remove_node (WEBKIT_DOM_NODE (marker));
marker = webkit_dom_document_get_element_by_id (
@@ -13631,30 +13747,47 @@ e_editor_dom_selection_restore (EEditorPage *editor_page)
@@ -13631,30 +13748,63 @@ e_editor_dom_selection_restore (EEditorP
parent_end = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker));
@ -244,11 +243,27 @@ index 3568f6e..35de5c0 100644
webkit_dom_node_normalize (parent_end);
}
if (start_is_anchor) {
- if (start_is_anchor) {
- anchor = webkit_dom_range_get_end_container (range, NULL);
- offset = webkit_dom_range_get_end_offset (range, NULL);
-
+ /* when restoring from:
+ <div>
+ <span id='sel-start'/>
+ <span id='sel-end'/>
+ <br>
+ </div>
+ the previous node is the 'div' and the next the 'br', while the original
+ selection was the 'div', both with 0 offset, thus special-case it here
+ to restore the selection properly
+ */
+ if (start_offset == 0 && end_offset == 0 &&
+ webkit_dom_node_is_same_node (start_node, webkit_dom_node_get_parent_node (end_node)) &&
+ webkit_dom_node_is_same_node (webkit_dom_node_get_first_child (start_node), end_node)) {
+ end_node = start_node;
+ }
- webkit_dom_range_collapse (range, TRUE, NULL);
+ if (start_is_anchor) {
+ anchor = start_node;
+ if (webkit_dom_node_is_same_node (start_node, end_node) && start_offset == end_offset)
+ end_node = NULL;
@ -283,11 +298,10 @@ index 3568f6e..35de5c0 100644
g_clear_object (&dom_selection);
g_clear_object (&range);
diff --git a/src/modules/webkit-editor/web-extension/e-editor-web-extension.c b/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
index d799db4..a286583 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
@@ -2465,8 +2465,10 @@ web_page_document_loaded_cb (WebKitWebPage *web_page,
diff -up evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-web-extension.c.webkitgtk-2.40 evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
--- evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-web-extension.c.webkitgtk-2.40 2018-07-30 15:37:05.000000000 +0200
+++ evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-web-extension.c 2024-03-14 16:53:57.706790972 +0100
@@ -2465,8 +2465,10 @@ web_page_document_loaded_cb (WebKitWebPa
if (!webkit_dom_dom_selection_get_anchor_node (dom_selection) &&
!webkit_dom_dom_selection_get_focus_node (dom_selection)) {
range = webkit_dom_document_caret_range_from_point (document, 0, 0);

View File

@ -31,7 +31,7 @@
Name: evolution
Version: 3.28.5
Release: 24%{?dist}
Release: 25%{?dist}
Group: Applications/Productivity
Summary: Mail and calendar client for GNOME
License: GPLv2+ and GFDL
@ -595,6 +595,9 @@ grep -v "/usr/share/locale" evolution.lang > help.lang
%endif
%changelog
* Thu Mar 14 2024 Milan Crha <mcrha@redhat.com> - 3.28.5-25
- Resolves: RHEL-29169 (Composer: Cursor jumps to the starting line when "return" key is pressed at the end of the line)
* Tue Dec 12 2023 Milan Crha <mcrha@redhat.com> - 3.28.5-24
- Resolves: RHEL-17661 (Composer: Cursor jumps over characters when using backspace or delete)