ui/popup: ensure existing buffers are reused

This resolves an issue where the popup manager would open another popup
if a previous one had been raised. The popup manager now delegates to
the existing buffer if it already exists (without resizing it).
This commit is contained in:
Henrik Lissner 2019-05-15 15:16:54 -04:00
parent c549091ce5
commit a22c035815
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -172,16 +172,23 @@ and enables `+popup-buffer-mode'."
(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)))
(when-let* ((popup (cl-loop for func in actions (or (let* ((alist (remove (assq 'window-width alist) alist))
if (funcall func buffer alist) (alist (remove (assq 'window-height alist) alist))
return it))) (window (display-buffer-reuse-window buffer alist)))
(+popup--init popup alist) (when window
(unless +popup--inhibit-select (unless +popup--inhibit-select
(let ((select (+popup-parameter 'select popup))) (select-window window))
(if (functionp select) window))
(funcall select popup origin) (when-let* ((popup (cl-loop for func in actions
(select-window (if select popup origin))))) if (funcall func buffer alist)
popup))) return it)))
(+popup--init popup alist)
(unless +popup--inhibit-select
(let ((select (+popup-parameter 'select popup)))
(if (functionp select)
(funcall select popup origin)
(select-window (if select popup origin)))))
popup))))
;;;###autoload ;;;###autoload
(defun +popup-parameter (parameter &optional window) (defun +popup-parameter (parameter &optional window)