jesseduffield / lazygit

simple terminal UI for git commands
MIT License
53.07k stars 1.85k forks source link

Refreshing custom patch view when adding commit files to custom patch #3258

Closed afhoffman closed 9 months ago

afhoffman commented 9 months ago

Describe the bug When adding a commit file to a custom patch, the bottom part of the right half displays title "Diff" and is empty. The view updates after hitting an arrow key to navigate to another file. Something is not refreshing properly when files are added to the patch builder.

To Reproduce Steps to reproduce the behavior:

  1. Navigate to the commits context
  2. Hit enter to view files in a commit
  3. Hit space to add file to custom patch

Expected behavior Immediately after adding a commit file to the patch builder, the view should update as in the "post-refresh" screenshot below.

Screenshots If applicable, add screenshots to help explain your problem. Pre-refresh:

pre-refresh

Post-refresh:

post-refresh

Version info: This happens on current master (05b97c8c), but does not happen on 0.40.2. I'm able to duplicate on macOS, Windows 11, and Ubuntu 22.04 (WSL).

Additional context Doing a git bisect, it looks like this behavior started after 240948b8. This change on my fork (https://github.com/afhoffman/lazygit/commit/d1f1ed0c28e686f24e655aaf4d2837972a8b2517) seems to fix it but I'm not totally sure why that fix works, and it doesn't feel right.

stefanhaller commented 9 months ago

Ah, when I made the 240948b88 commit I did feel uncomfortable about it and wondered what would break. I was actually a bit surprised that nothing broke (apparently)... Thanks for the very clear bug report, and for bisecting it.

BTW, we have a similar problem in the Files view, but it's a bit harder to reproduce. The only reproduction recipe I could come up with so far is this:

This also broke with 240948b, so it's likely the same root cause. I'll look into it.

stefanhaller commented 9 months ago

Here's a proposal for a fix: #3266