File autofocus fails on embed folders
- Dominant language
- Rust
- Stars
- 22.5k
- Forks
- 773
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Suppose we have folder structure like this
```
ββπ level_1
β βββπ level_2
β βββ File1
ββπ level_1
βββπ level_2
β βββπ level_3
β βββ File2
βββFile3
```
If we start staging file from top to bottom then after staging File1 we will end up focused on folder `level_3` but not the first changed file on the list.
This generally affects two places - folder tree view and diff view. Tree view sets focus on the folder and diff view just becomes empty, since cursor focused on the folder.
If start to stage things from the bottom up it's obviously will focus on the last changed file and works just as intended.
**To Reproduce**
Have folder structure similar to above
Start staging files from up to bottom.
**Expected behavior**
Automatic focus on next file changed, not an offset from common root.
**Screenshots**
I have asciinema recording with example: [gitui_bug.txt](https://github.com/extrawurst/gitui/files/13430558/gitui_bug.txt)
to replay
```
asciinema play gitui_bug.txt
```
First we stage bottom up and everything goes fine, then unstage all and start stage from up to bottom and the view becomes blank after first stage and tree focused on the folder.
**Context:**
- GitUI Version [e.g. `0.24.3`]
Contributor guide
Assessment
This issue has not been assessed yet.