mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Use correct previous word location when moving selection offset
Previously, this incorrect offset could cause a crash when moving the selection to the previous word.
This commit is contained in:
parent
1eb581815a
commit
6ee91c4189
Notes:
github-actions[bot]
2025-07-03 09:30:01 +00:00
Author: https://github.com/tcl3
Commit: 6ee91c4189
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5246
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 28 additions and 1 deletions
|
@ -629,7 +629,7 @@ void Selection::move_offset_to_previous_word(bool collapse_selection)
|
|||
while (true) {
|
||||
auto focus_offset = this->focus_offset();
|
||||
if (auto offset = text_node.word_segmenter().previous_boundary(focus_offset); offset.has_value()) {
|
||||
auto word = text_node.data().code_points().substring_view(focus_offset, focus_offset - *offset);
|
||||
auto word = text_node.data().code_points().unicode_substring_view(*offset, focus_offset - *offset);
|
||||
if (collapse_selection) {
|
||||
MUST(collapse(anchor_node, *offset));
|
||||
m_document->reset_cursor_blink_cycle();
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
dialog {
|
||||
display: table-header-group;
|
||||
translate: -1px 0px 0px;
|
||||
position: sticky;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
addEventListener("DOMContentLoaded", () => {
|
||||
window.find("1");
|
||||
getSelection().modify("move", "left", "word");
|
||||
}, {once: true});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<dialog>
|
||||
<span style="position: fixed">1</span>
|
||||
<table dir="rtl"></table>
|
||||
<video>
|
||||
</video>
|
||||
</dialog>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue