diff --git a/Libraries/LibUnicode/CharacterTypes.cpp b/Libraries/LibUnicode/CharacterTypes.cpp index 112eaf1e641..fd874cdb075 100644 --- a/Libraries/LibUnicode/CharacterTypes.cpp +++ b/Libraries/LibUnicode/CharacterTypes.cpp @@ -123,6 +123,11 @@ bool code_point_has_letter_general_category(u32 code_point) return code_point_has_general_category(code_point, GENERAL_CATEGORY_LETTER); } +bool code_point_has_mark_general_category(u32 code_point) +{ + return code_point_has_general_category(code_point, GENERAL_CATEGORY_MARK); +} + bool code_point_has_number_general_category(u32 code_point) { return code_point_has_general_category(code_point, GENERAL_CATEGORY_NUMBER); diff --git a/Libraries/LibUnicode/CharacterTypes.h b/Libraries/LibUnicode/CharacterTypes.h index c2a98ebb2ff..a49a56a007b 100644 --- a/Libraries/LibUnicode/CharacterTypes.h +++ b/Libraries/LibUnicode/CharacterTypes.h @@ -8,7 +8,6 @@ #include #include -#include #include #include @@ -20,6 +19,7 @@ bool code_point_has_general_category(u32 code_point, GeneralCategory general_cat bool code_point_is_printable(u32 code_point); bool code_point_has_control_general_category(u32 code_point); bool code_point_has_letter_general_category(u32 code_point); +bool code_point_has_mark_general_category(u32 code_point); bool code_point_has_number_general_category(u32 code_point); bool code_point_has_punctuation_general_category(u32 code_point); bool code_point_has_separator_general_category(u32 code_point); diff --git a/Libraries/LibWeb/Editing/Commands.cpp b/Libraries/LibWeb/Editing/Commands.cpp index 0f3df614ecf..9222eafc719 100644 --- a/Libraries/LibWeb/Editing/Commands.cpp +++ b/Libraries/LibWeb/Editing/Commands.cpp @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include -#include #include #include #include @@ -935,10 +935,15 @@ bool command_forward_delete_action(DOM::Document& document, Utf16String const&) // 5. If node is a Text node and offset is not node's length: if (auto const* text_node = as_if(*node); text_node && offset != node->length()) { // 1. Let end offset be offset plus one. - auto end_offset = text_node->grapheme_segmenter().next_boundary(offset).value_or(offset + 1); + auto& grapheme_segmenter = text_node->grapheme_segmenter(); + auto end_offset = grapheme_segmenter.next_boundary(offset).value_or(offset + 1); - // FIXME: 2. While end offset is not node's length and the end offsetth code unit of node's data has general category M + // 2. While end offset is not node's length and the end offsetth code unit of node's data has general category M // when interpreted as a Unicode code point, add one to end offset. + while (end_offset != node->length() + && Unicode::code_point_has_mark_general_category(text_node->data().code_point_at(end_offset))) { + end_offset = grapheme_segmenter.next_boundary(end_offset).value_or(end_offset + 1); + } // 3. Call collapse(node, offset) on the context object's selection. MUST(selection.collapse(node, offset));