branch: elpa/magit
commit 2419a5295ea6300a437df678afe9c2facf1c9696
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-diff--dwim: Only fallback to magit-buffer-diff-type
In [1: d20fe25bb3] we started returning `magit-buffer-diff-type's value
when in a `magit-diff-mode' buffer, but that is only appropriate if
that is `unstaged', `staged' or `undefined' (i.e., when no more precise
information is available). For the only other and most common case,
`committed', we must return `magit-buffer-range's value.
1: 2025-07-30 d20fe25bb397f4a9ae51a24b266a83c216e7ab35
magit-diff--dwim: Honor magit-buffer-diff-type
---
lisp/magit-diff.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 11df4d79ed6..58213e0d377 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -1214,7 +1214,9 @@ If no DWIM context is found, nil is returned."
((derived-mode-p 'magit-revision-mode)
(cons 'commit magit-buffer-revision))
((derived-mode-p 'magit-diff-mode)
- (or magit-buffer-diff-type magit-buffer-range))
+ (pcase-exhaustive magit-buffer-diff-type
+ ('committed magit-buffer-range)
+ ((or 'unstaged 'staged 'undefined) magit-buffer-diff-type)))
(t
(magit-section-case
([* unstaged] 'unstaged)