Skip to content

git_ui: Enable navigation for single-hunk diffs - #62615

Open
macayu17 wants to merge 2 commits into
zed-industries:mainfrom
macayu17:fix/62469-single-hunk-navigation
Open

git_ui: Enable navigation for single-hunk diffs#62615
macayu17 wants to merge 2 commits into
zed-industries:mainfrom
macayu17:fix/62469-single-hunk-navigation

Conversation

@macayu17

@macayu17 macayu17 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

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

single-hunk-navigation-clean.mp4

Self-Review Checklist

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed hunk navigation being disabled for single-hunk diffs.

Copilot AI lite review requested due to automatic review settings August 14, 2026 08:39
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dinocosta dinocosta added the area:integrations/git Git integration feedback label Aug 14, 2026

@dinocosta dinocosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @macayu17 ! Thank you for taking a stab at this 🙂

Sorry to ask but I'm wondering if you did manage to test these changes yourself, given the following in the Pull Request description, which makes it seem like you were unable to compile the code on your end.

Attempted cargo test -p git_ui solo_diff_view::tests::test_changes_only_multibuffer_has_one_buffer_and_expand_controls; compilation could not complete because MSVC link.exe is unavailable in the local environment.

If possible, can you attach a screen recording showing the updated UI? Thanks!

@macayu17

Copy link
Copy Markdown
Contributor Author

Thanks for checking. I rebuilt the branch using the Windows GNU toolchain and ran the full git_ui library suite. All 130 tests passed. I also verified the single-hunk navigation in the branch-built app and attached a screen recording above.

@macayu17
macayu17 requested a review from dinocosta August 14, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:integrations/git Git integration feedback cla-signed The user has signed the Contributor License Agreement

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Single-hunk diff view: no way to navigate back to the hunk after scrolling away

3 participants