Skip to content

Commit

Permalink
Only enable dynamic exhibit delay while typing
Browse files Browse the repository at this point in the history
Fixes abo-abo#1218

Adds an extra check to `ivy--queue-exhibit` to only debounce if the input has
actually changed. It also maintains the previous input variable to match against.
  • Loading branch information
Gleek authored and kiennq committed Nov 29, 2023
1 parent a884380 commit b1f2327
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -3347,22 +3347,25 @@ Otherwise, ~/ will move home."
"Delay in ms before dynamic collections are refreshed"
:type 'integer)

(defvar ivy--queue-last-input nil)
(defvar ivy--exhibit-timer nil)

(defun ivy--queue-exhibit ()
"Insert Ivy completions display, possibly after a timeout for
dynamic collections.
Should be run via minibuffer `post-command-hook'."
(if (and (> ivy-dynamic-exhibit-delay-ms 0)
(ivy-state-dynamic-collection ivy-last))
(ivy-state-dynamic-collection ivy-last)
(not (equal ivy--queue-last-input (ivy--input))))
(progn
(when ivy--exhibit-timer (cancel-timer ivy--exhibit-timer))
(setq ivy--exhibit-timer
(run-with-timer
(/ ivy-dynamic-exhibit-delay-ms 1000.0)
nil
'ivy--exhibit)))
(ivy--exhibit)))
(ivy--exhibit))
(setq ivy--queue-last-input (ivy--input)))

(defalias 'ivy--file-local-name
(if (fboundp 'file-local-name)
Expand Down

0 comments on commit b1f2327

Please sign in to comment.