servo/tests/unit/script
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
..
Cargo.toml Add rust-version to all Cargo.toml files (#33483) 2024-09-17 16:39:07 +00:00
headers.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
htmlareaelement.rs Format remaining files 2018-11-06 22:30:31 +01:00
htmlimageelement.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
lib.rs Update MPL license to https (part 5) 2018-11-27 19:09:17 +01:00
origin.rs Update MPL license to https (part 5) 2018-11-27 19:09:17 +01:00
size_of.rs dom: Move child_list to rare data (#35592) 2025-02-22 01:32:37 +00:00
textinput.rs Fix Backspace deleting entire previous line in <textarea> (#36112) 2025-03-26 18:37:48 +00:00
timeranges.rs Fixed some clippy warning by adding default implementations (#31989) 2024-04-04 09:33:30 +00:00