Skip to content

Commit

Permalink
Close popup when window selection changes (Fix #112)
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed Apr 25, 2023
1 parent 9391939 commit 00cca1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Development

- Ensure that the popup font matches the font of the parent frame.
- Close popup when window selection changes.

* Version 0.36 (2023-03-27)

Expand Down
6 changes: 5 additions & 1 deletion corfu.el
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ FRAME is the existing frame."
(activate-change-group (setq corfu--change-group (prepare-change-group)))
(setcdr (assq #'completion-in-region-mode minor-mode-overriding-map-alist) corfu-map)
(add-hook 'pre-command-hook #'corfu--prepare nil 'local)
(add-hook 'window-selection-change-functions #'corfu-quit nil 'local)
(add-hook 'window-buffer-change-functions #'corfu-quit nil 'local)
(add-hook 'post-command-hook #'corfu--post-command)
;; Disable default post-command handling, since we have our own
;; checks in `corfu--post-command'.
Expand Down Expand Up @@ -1074,6 +1076,8 @@ AUTO is non-nil when initializing auto completion."
(cl-defgeneric corfu--teardown ()
"Tear-down Corfu."
(corfu--popup-hide)
(remove-hook 'window-selection-change-functions #'corfu-quit 'local)
(remove-hook 'window-buffer-change-functions #'corfu-quit 'local)
(remove-hook 'pre-command-hook #'corfu--prepare 'local)
(remove-hook 'post-command-hook #'corfu--post-command)
(when corfu--preview-ov (delete-overlay corfu--preview-ov))
Expand All @@ -1084,7 +1088,7 @@ AUTO is non-nil when initializing auto completion."
"Sort LIST by length and alphabetically."
(sort list #'corfu--length-string<))

(defun corfu-quit ()
(defun corfu-quit (&rest _)
"Quit Corfu completion."
(interactive)
(completion-in-region-mode -1))
Expand Down

0 comments on commit 00cca1f

Please sign in to comment.