Skip to content

Unable to exit git forgit diff on ZSH in Windows with Delta #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marovira opened this issue Feb 19, 2025 · 6 comments
Closed

Unable to exit git forgit diff on ZSH in Windows with Delta #423

marovira opened this issue Feb 19, 2025 · 6 comments

Comments

@marovira
Copy link

Issue

On Windows with the following setup:

  • Git bash with ZSH
  • core.pager = delta --side-by-side --width ${FZF_PREVIEW_COLUMNS-$COLUMNS}
  • Latest version of forgit and fzf.

In a repo with a changed file, if I enter git forgit diff, the fzf menu correctly pops up displaying the changed file. If I enter ?, the diff preview is correctly shown. Now, if I press enter, the diff is opened in delta. At this point, no matter what key (or combination of keys) I press, there's no way to exit delta to return to the terminal.

Here's the diff preview working correctly:
Image

If I press enter to select zsh/zshrc, I enter this screen:
Image
At which point no matter what key I press there's no way to exit back to the terminal.

Observations

  • Running git diff directly works without issue.
  • When I enter the second screen shown above, a less process is spawned which appears to be blocking everything. What's interesting is that if I press any regular key (like j, k, etc) and I then kill the process using Task Manager, those keys are shown as being entered into fzf's prompt. This leads me to believe that for some reason fzf appears to be swallowing the key presses that should've been going to delta.
  • This issue is exclusive to Windows. Under Linux, the issue does not occur.

Config

Relevant git config:

[core]
    pager = delta --side-by-side --width ${FZF_PREVIEW_COLUMNS-$COLUMNS}

[delta]
    syntax-theme = Dracula
    decorations = true
    navigate = true
    dark = true
    line-numbers = true
    side-by-side = true

[delta "decorations"]
    commit-decoration-style = bold yellow box ul
    file-style = bold yellow ul
    file-decoration-style = none
    hunk-header-decoration-style = cyan box ul

[delta "line-numbers"]
    line-numbers-left-style = cyan
    line-numbers-right-style = cyan
    line-numbers-minus-style = 124
    line-numbers-plus-style = 28

Note

Please ignore the weird rendering on delta's output. I had to resize the window to make sure the screenshots didn't come out huge and that messed up with the display.

@carlfriedrich
Copy link
Collaborator

Thanks for reporting the issue. Interesting case. The command we execute when pressing enter in git forgit diff when called without any arguments is:

git forgit diff_enter <file> | git forgit pager enter

Can you check what happens if you call that command directly for your file (git forgit diff_enter zsh/zshrc | git forgit pager enter)?

@marovira
Copy link
Author

marovira commented Feb 19, 2025

Thanks for the quick reply!
Entering those commands directly works correctly . Keys are received by delta and I can return to the terminal without issue. It appears that this only occurs when the diff is launched from fzf.

@carlfriedrich
Copy link
Collaborator

@marovira Thanks for your feedback. Then the next step to isolate the problem would be a simplified version of how we call fzf in our diff function:

echo "zsh/zshrc" | fzf --bind="enter:execute(git forgit diff_enter {} | git forgit pager enter)"

And also we could check the simplest combination of fzf with less:

echo "zsh/zshrc" | fzf --bind="enter:execute(less {})"

How do these two work?

@marovira
Copy link
Author

marovira commented Feb 19, 2025

Ok so:

  • echo "zsh/zshrc" | fzf --bind="enter:execute(git forgit diff_enter {} | git forgit pager enter)" results in:
    • The fzf prompt showing up with zsh/zshrc being selected.
    • Pressing enter causes delta to show up and the less process to be created.
    • No key presses are received by delta. Killing the less process shows that they're being swallowed by fzf.
  • echo "zsh/zshrc" | fzf --bind="enter:execute(less {})" results in:
    • The fzf prompt showing up with zsh/zshrc being selected.
    • Pressing enter causes less to show up. Major difference: the less process is still created, but this time it is marked as a child of the main zsh process instead of being a separate process.
    • No key presses are received by less. Killing the less child process shows that they're being swallowed by fzf.

I'm not sure if the fact that the less process appears as a child of zsh is relevant or not, but there's definitely an issue with the interaction between less and fzf.

@carlfriedrich
Copy link
Collaborator

Thanks for checking. The difference concerning the process is probably caused by less being called in a pipe in the first example, and being called directly in the second example.

So obviously this is not a problem with forgit. I would suggest that you open an upstream issue for fzf based on the second example.

@carlfriedrich carlfriedrich closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2025
@marovira
Copy link
Author

marovira commented Feb 19, 2025

Thanks for the help @carlfriedrich!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants