mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 06:29:43 +00:00
LibWeb: Delete entire graphemes when the delete/backspace key is pressed
We currently delete a single code unit. If the user presses backspace on a multi code point emoji, they are going to expect the entire emoji to be removed. This now matches the behavior of Chrome and Firefox.
This commit is contained in:
parent
76bab90812
commit
c369f68eff
Notes:
github-actions[bot]
2025-08-14 20:22:53 +00:00
Author: https://github.com/trflynn89
Commit: c369f68eff
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5859
Reviewed-by: https://github.com/gmta ✅
8 changed files with 69 additions and 19 deletions
|
@ -829,13 +829,12 @@ void FormAssociatedTextControlElement::handle_delete(DeleteDirection direction)
|
|||
|
||||
if (selection_start == selection_end) {
|
||||
if (direction == DeleteDirection::Backward) {
|
||||
if (selection_start > 0)
|
||||
MUST(set_range_text({}, selection_start - 1, selection_end, Bindings::SelectionMode::End));
|
||||
if (auto offset = text_node->grapheme_segmenter().previous_boundary(m_selection_end); offset.has_value())
|
||||
selection_start = *offset;
|
||||
} else {
|
||||
if (selection_start < text_node->length_in_utf16_code_units())
|
||||
MUST(set_range_text({}, selection_start, selection_end + 1, Bindings::SelectionMode::End));
|
||||
if (auto offset = text_node->grapheme_segmenter().next_boundary(m_selection_end); offset.has_value())
|
||||
selection_end = *offset;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
MUST(set_range_text({}, selection_start, selection_end, Bindings::SelectionMode::End));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue