branch: elpa/magit
commit 9ac9c36b4e3cf506173140550720ccba35a06e75
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    magit-diff-visit-file--setup: Do not require visible buffer
    
    Do not require a visible window to display the buffer, or any
    window for that matter.  Either is unlikely to happen, but given
    an odd display function it is theoretically possible.  We can set
    point even if no window displays the buffer, so do not needlessly
    signal an error should either unexpectedly happen.
    
    [1: 0679c015a9] was right to ensure the correct window is selected
    but failing if no visible window displays it went too far.
    
    1: 2017-05-22 0679c015a9255c848cd4d9d8a71828ba45887590
       magit-diff-visit-file: adjust point in correct window
---
 lisp/magit-diff.el | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index b3e0f3bdc13..fc59c0bd83d 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -1736,17 +1736,16 @@ the Magit-Status buffer for DIRECTORY."
       (magit-status-setup-buffer directory))))
 
 (defun magit-diff-visit-file--setup (buf pos)
-  (if-let ((win (get-buffer-window buf 'visible)))
-      (with-selected-window win
-        (when pos
-          (unless (<= (point-min) pos (point-max))
-            (widen))
-          (goto-char pos))
-        (when (and buffer-file-name
-                   (magit-anything-unmerged-p buffer-file-name))
-          (smerge-start-session))
-        (run-hooks 'magit-diff-visit-file-hook))
-    (error "File buffer is not visible")))
+  (with-selected-window (or (get-buffer-window buf) (selected-window))
+    (with-current-buffer buf
+      (when pos
+        (unless (<= (point-min) pos (point-max))
+          (widen))
+        (goto-char pos))
+      (when (and buffer-file-name
+                 (magit-anything-unmerged-p buffer-file-name))
+        (smerge-start-session))
+      (run-hooks 'magit-diff-visit-file-hook))))
 
 (defun magit-diff-visit-file--noselect (&optional file goto-worktree)
   (unless file

Reply via email to