servo/tests/unit
elomscansio 30a2a89d16
Fix Backspace deleting entire previous line in <textarea> (#36112)
* test(textinput): Add test for backspace at beginning of line in textarea

Introduce a test to reproduce and verify the fix for backspacing at the
beginning of a line in a multiline textarea. This ensures that pressing
Backspace when the cursor is at the start of a line correctly removes the
newline without deleting the entire previous line’s content.

Related to: #27523

Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>

* fix(textinput): Preserve selection origin when adjusting vertical position

Fixes an issue where pressing Backspace at the beginning of a line in a
textarea incorrectly deleted the entire previous line's content. This happened
because `self.adjust_vertical(-1, select)` modified `selection_origin` and
`edit_point`, but `selection_origin` was not restored before performing the
horizontal adjustment. As a result, `self.selection_start()` and
`self.selection_end()` were inconsistent, leading to `replace_operation`
erasing the entire line.

Now, we temporarily store `selection_origin` before adjusting vertical
position and restore it afterward to ensure proper cursor and selection
behavior.

Fixes: #27523
Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>

---------

Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-03-26 18:37:48 +00:00
..
deny_public_fields Add rust-version to all Cargo.toml files (#33483) 2024-09-17 16:39:07 +00:00
malloc_size_of Add rust-version to all Cargo.toml files (#33483) 2024-09-17 16:39:07 +00:00
profile deps: Upgrade to webrender@0.66 (#35325) 2025-02-07 11:57:26 +00:00
script Fix Backspace deleting entire previous line in <textarea> (#36112) 2025-03-26 18:37:48 +00:00
style Cleanup Stylo dependencies (#36046) 2025-03-19 08:53:26 +00:00