cursor_up_one_row moves to same column when cursor starts at end of line
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
**Bug Description**
When moving the cursor up a row while it's at the end of a line, it moves to a place the same number of characters from the beginning of the new line as it was from the beginning of the old line. This is instead of the usual (seemingly more correct) behavior of moving to a place the same distance from the beginning of the line.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to https://www.egui.rs/#easymark (the bug is affecting our project as well, but this is easier for demonstration)
2. Replace the text with:
>wwwww
lllll
3. Place cursor at the end of the second line
4. Arrow up
5. The cursor ends up at the end of the first line
**Expected behavior**
The cursor ends up after the 2nd 'w' in the first line
**Screenshots**
https://user-images.githubusercontent.com/6198756/208146805-d4fd5a86-1338-4ae4-8dcf-e9e92bec5572.mov
**Additional context**
This behavior appears to be addressed as a special case [here](https://github.com/emilk/egui/blame/master/crates/epaint/src/text/text_layout_types.rs#L840-L846) in a commit with message "Fix some edge cases for the cursor movement" so it's likely this is intentional behavior, but I don't understand why.
Contributor guide
Research direction
Start with crates/epaint/src/text/text_layout_types.rs around lines 840-846, where the linked special case handles cursor movement, and reproduce the behavior with the two-line w/l example in the issue. Determine why cursor_up_one_row selects the end of the first line instead of the position after the second “w”; done means the expected movement is restored and the behavior is covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100