summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--corfu.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/corfu.el b/corfu.el
index c3cc2d9..097ea9b 100644
--- a/corfu.el
+++ b/corfu.el
@@ -368,7 +368,8 @@ The completion backend can override this with
(defun corfu--popup-redirect-focus ()
"Redirect focus from popup."
- (redirect-frame-focus corfu--frame (frame-parent corfu--frame)))
+ (when (and (frame-live-p corfu--frame) (eq (selected-frame) corfu--frame))
+ (redirect-frame-focus corfu--frame (frame-parent corfu--frame))))
(defun corfu--make-buffer (content)
"Create corfu buffer with CONTENT."
@@ -376,8 +377,6 @@ The completion backend can override this with
(ls line-spacing)
(buffer (get-buffer-create " *corfu*")))
(with-current-buffer buffer
- ;;; XXX HACK install redirect focus hook
- (add-hook 'pre-command-hook #'corfu--popup-redirect-focus nil 'local)
;;; XXX HACK install mouse ignore map
(use-local-map corfu--mouse-ignore-map)
(dolist (var corfu--buffer-parameters)
@@ -1213,7 +1212,9 @@ Auto completion is only performed if the tick did not change."
;; advice is active *globally*.
(advice-add #'completion--capf-wrapper :around #'corfu--capf-wrapper-advice)
(advice-add #'eldoc-display-message-no-interference-p :before-while #'corfu--allow-eldoc)
- (and corfu-auto (add-hook 'post-command-hook #'corfu--auto-post-command nil 'local))
+ ;;; XXX HACK install redirect focus hook
+ (add-function :after after-focus-change-function #'corfu--popup-redirect-focus)
+ (when corfu-auto (add-hook 'post-command-hook #'corfu--auto-post-command nil 'local))
(setq-local completion-in-region-function #'corfu--in-region))
(t
(remove-hook 'post-command-hook #'corfu--auto-post-command 'local)