# git_ui: Enable navigation for single-hunk diffs \(\#62615\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/d0bfe0a4535ec373e2930245d5d370e045dbf11f)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: d0bfe0a4535ec373e2930245d5d370e045dbf11f

Requested commit: d0bfe0a4535ec373e2930245d5d370e045dbf11f

Commit: d0bfe0a4535ec373e2930245d5d370e045dbf11f

Tree: 385afcc4043b9f6194b483e1b8df3a2ceed92264

Author: Ayush

Committer: GitHub

## Message

```
git_ui: Enable navigation for single-hunk diffs (#62615)

## What

Keep the hunk navigation controls available when a diff contains one
hunk, so users can return to it after scrolling away. This applies to
solo, staged, unstaged, and project diff views.

## Why

The controls were only rendered when `hunk_count > 1`, even though the
existing navigation actions already wrap and recenter a single hunk.

## How

Render the previous and next hunk controls whenever `hunk_count > 0`,
reusing the existing navigation actions.

Closes #62469

## Testing

- `cargo +stable-x86_64-pc-windows-gnu test -p git_ui --lib` — 130
passed.
- `cargo +stable-x86_64-pc-windows-gnu build -p zed -j 1` — passed.
- `rustfmt --edition 2024 --check` on the four changed files — passed.
- `git diff --check` — passed.
- Manually verified with the branch-built Zed on Windows: opened a
tracked file with exactly one diff hunk, expanded the context, scrolled
below the hunk, and used **Go to Previous Hunk**. The view returned to
the changed line.

## Showcase


https://github.com/user-attachments/assets/e7b63030-50ad-4536-8266-13987ed85f3d

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://zed.dev/docs/development/ux-ui) and [icon
guidelines](https://zed.dev/docs/development/ui-icons))
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Enable "Go to Previous Hunk" and "Go to Next Hunk" buttons even if
there's a single diff hunk.
```

## Parents

- [6dee3fc7559e70b086711a864e9d02169c617c21](https://git.cafe/gitcafe/zed/commit/6dee3fc7559e70b086711a864e9d02169c617c21?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/d0bfe0a4535ec373e2930245d5d370e045dbf11f?format=markdown)
