dandavison / magit-delta

Use delta (https://github.com/dandavison/delta) when viewing diffs in Magit
MIT License
288 stars 10 forks source link

discard region cannot succeed when delta in side-by-side mode #7

Closed lyjdwh closed 4 years ago

lyjdwh commented 4 years ago

my delta config in ~/.gitconfig

[core]
    pager=delta
[delta]
    side-by-side = true
    line-numbers-left-format = ""
    line-numbers-right-format = "│ "
[interactive]
    diffFilter = delta --color-only

when I discard region in magit status buffer, it doesn't succeed. The error message is "error:patch failed"

dandavison commented 4 years ago

Hi @lyjdwh thanks for this. It was occurring for me too. Can you try the latest delta (>= 0.4.1)? I believe this is fixed (in that side-by-side is disabled automatically when --color-only is in effect. Since magit-delta-delta-args includes `--color-only this problem should not occur.)

lyjdwh commented 4 years ago

Thanks for your help! I wonder is there a way to use delta side-by-side in magit-delta?

dandavison commented 4 years ago

I believe you'd need to write some sort of magit extension for that: magit requires that the content displayed as a diff is a correctly-formatted patch. (Essentially magit sends the hunks from Emacs to the stdin of git apply, at least that is my memory of the magit code). So I believe you'd need to write something that converts the side-by-side diff back to conventional patch format.