emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/corfu-doc d857f012ad 33/95: Reduce doc frame flickering


From: ELPA Syncer
Subject: [elpa] externals/corfu-doc d857f012ad 33/95: Reduce doc frame flickering when the delay is very low
Date: Tue, 19 Jul 2022 15:58:02 -0400 (EDT)

branch: externals/corfu-doc
commit d857f012ad7ca008ab5dcc179dfe16e2d6384532
Author: Yuwei Tian <ibluefocus@outlook.com>
Commit: Yuwei Tian <ibluefocus@outlook.com>

    Reduce doc frame flickering when the delay is very low
---
 corfu-doc.el | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/corfu-doc.el b/corfu-doc.el
index 02e9e8d138..247936c726 100644
--- a/corfu-doc.el
+++ b/corfu-doc.el
@@ -49,6 +49,16 @@
   :safe #'floatp
   :group 'corfu-doc)
 
+(defcustom corfu-doc-hide-threshold 0.2
+  "Threshold value to hide the documentation popup when browsing candidates.
+
+When the selected candidate is changed, if the value of `corfu-doc-delay'
+is greater than this threshold value, the documentation popup frame will
+be hided immediately. Else, just clear the doc frame content."
+  :type 'float
+  :safe #'floatp
+  :group 'corfu-doc)
+
 (defcustom corfu-doc-max-width 60
   "The max width of the corfu doc frame in characters."
   :type 'integer
@@ -293,6 +303,12 @@ If this is nil, do not resize corfu doc frame 
automatically."
   (and (> corfu--total 0)
        (nth corfu--index corfu--candidates)))
 
+(defun corfu-doc--clear-buffer ()
+  (with-current-buffer
+      (window-buffer (frame-root-window corfu-doc--frame))
+    (let ((inhibit-read-only t))
+      (erase-buffer))))
+
 (defun corfu-doc--show ()
   (when (and (and (fboundp 'corfu-mode) corfu-mode)
              (frame-visible-p corfu--frame))
@@ -332,7 +348,9 @@ If this is nil, do not resize corfu doc frame 
automatically."
                  (eq (selected-window) corfu-doc--window))
       (when (and (frame-live-p corfu-doc--frame)
                  (frame-visible-p corfu-doc--frame))
-        (make-frame-invisible corfu-doc--frame))))
+        (if (> corfu-doc-delay corfu-doc-hide-threshold)
+            (make-frame-invisible corfu-doc--frame)
+          (corfu-doc--clear-buffer)))))
   (when (or (null corfu-doc--timer)
             (eq this-command #'corfu-doc-manually))
     (setq corfu-doc--timer
@@ -350,10 +368,7 @@ If this is nil, do not resize corfu doc frame 
automatically."
 (defun corfu-doc--hide ()
   (when (frame-live-p corfu-doc--frame)
     (make-frame-invisible corfu-doc--frame)
-    (with-current-buffer
-        (window-buffer (frame-root-window corfu-doc--frame))
-      (let ((inhibit-read-only t))
-        (erase-buffer)))
+    (corfu-doc--clear-buffer)
     (setq corfu-doc--candidate nil)
     (setq corfu-doc--cf-frame-edges nil)
     (setq corfu-doc--window nil)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]