branch: externals/corfu-doc
commit c968530f748bdf30c56cf8221109d4cc23558dbf
Author: Frédéric Giquel <[email protected]>
Commit: Yuwei Tian <[email protected]>
Fix #9: fix showing doc while quickly browsing candidates
This fixes a problem pointed out by
Frédéric Giquel <[email protected]>.
---
corfu-doc.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/corfu-doc.el b/corfu-doc.el
index 87036ebad7..aa9b0c83f1 100644
--- a/corfu-doc.el
+++ b/corfu-doc.el
@@ -340,9 +340,10 @@ FWIDTH and FHEIGHT."
(setq corfu-doc--cf-frame-edges nil)
(setq corfu-doc--window nil)))
-(defun corfu-doc--show ()
+(defun corfu-doc--show (&optional candidate-index)
(when (and (and (fboundp 'corfu-mode) corfu-mode)
- (frame-visible-p corfu--frame))
+ (frame-visible-p corfu--frame)
+ (equal candidate-index corfu--index))
(when-let ((candidate (corfu-doc--get-candidate))
(cf-frame-edges (frame-edges corfu--frame 'inner)))
(if (and (string= candidate corfu-doc--candidate)
@@ -423,7 +424,7 @@ FWIDTH and FHEIGHT."
(corfu-doc--hide)))))
(when (and corfu-doc-mode corfu-doc-auto)
(setq corfu-doc--timer
- (run-with-timer corfu-doc-delay nil #'corfu-doc--show))))
+ (run-with-timer corfu-doc-delay nil #'corfu-doc--show
corfu--index))))
(defun corfu-doc--cleanup ()
(advice-remove 'corfu--popup-hide #'corfu-doc--cleanup)