Record origin window earlier

The selected window could change in between +popup--maybe-select-window calls.
This commit is contained in:
Henrik Lissner 2019-12-03 19:59:27 -05:00 committed by GitHub
parent 359ae77250
commit 79faa02d6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -132,11 +132,10 @@ the buffer is visible, then set another timer and try again later."
(let ((ignore-window-parameters t)) (let ((ignore-window-parameters t))
(split-window window size side))) (split-window window size side)))
(defun +popup--maybe-select-window (window) (defun +popup--maybe-select-window (window &optional origin)
"Select a window based on `+popup--inhibit-select' and this window's `select' parameter." "Select a window based on `+popup--inhibit-select' and this window's `select' parameter."
(unless +popup--inhibit-select (unless +popup--inhibit-select
(let ((origin (selected-window)) (let ((select (+popup-parameter 'select window)))
(select (+popup-parameter 'select window)))
(if (functionp select) (if (functionp select)
(funcall select window origin) (funcall select window origin)
(select-window (if select window origin)))))) (select-window (if select window origin))))))
@ -188,7 +187,8 @@ and enables `+popup-buffer-mode'."
;;;###autoload ;;;###autoload
(defun +popup-buffer (buffer &optional alist) (defun +popup-buffer (buffer &optional alist)
"Open BUFFER in a popup window. ALIST describes its features." "Open BUFFER in a popup window. ALIST describes its features."
(let* ((window-min-height 3) (let* ((origin (selected-window))
(window-min-height 3)
(alist (+popup--normalize-alist alist)) (alist (+popup--normalize-alist alist))
(actions (or (cdr (assq 'actions alist)) (actions (or (cdr (assq 'actions alist))
+popup-default-display-buffer-actions))) +popup-default-display-buffer-actions)))
@ -196,13 +196,13 @@ and enables `+popup-buffer-mode'."
(alist (remove (assq 'window-height alist) alist)) (alist (remove (assq 'window-height alist) alist))
(window (display-buffer-reuse-window buffer alist))) (window (display-buffer-reuse-window buffer alist)))
(when window (when window
(+popup--maybe-select-window window) (+popup--maybe-select-window window origin)
window)) window))
(when-let (popup (cl-loop for func in actions (when-let (popup (cl-loop for func in actions
if (funcall func buffer alist) if (funcall func buffer alist)
return it)) return it))
(+popup--init popup alist) (+popup--init popup alist)
(+popup--maybe-select-window popup) (+popup--maybe-select-window popup origin)
popup)))) popup))))
;;;###autoload ;;;###autoload