gitui-org / gitui-org/gitui

File autofocus fails on embed folders

Open
#1,958 2 comments 0 reactions 0 assignees View on GitHub
bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.