From 143266aca598a238a0231a7f3f0aa22fdac364ee Mon Sep 17 00:00:00 2001 From: 1nc0n Date: Fri, 18 Sep 2020 23:38:59 +0100 Subject: [PATCH 1/3] fixed #1218 aggressive debounce for dynamic-collection --- ivy.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ivy.el b/ivy.el index ed5f6aab..106b7d05 100644 --- a/ivy.el +++ b/ivy.el @@ -3227,12 +3227,20 @@ Otherwise, ~/ will move home." (defvar ivy--exhibit-timer nil) +(let (last-pos) + (defun ivy-input-changed? () + (let* ((pos (line-end-position)) + (changed (not (eq pos last-pos)))) + (setq last-pos pos) + changed))) + (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) + (ivy-input-changed?)) (progn (when ivy--exhibit-timer (cancel-timer ivy--exhibit-timer)) (setq ivy--exhibit-timer From e0f57dd0e4d60d846068a13895c4d5b4deefb692 Mon Sep 17 00:00:00 2001 From: 1nc0n Date: Sat, 19 Sep 2020 15:33:59 +0100 Subject: [PATCH 2/3] additional style and optimization fixes for pull request #2678 --- ivy.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ivy.el b/ivy.el index 106b7d05..115949e0 100644 --- a/ivy.el +++ b/ivy.el @@ -3227,12 +3227,12 @@ Otherwise, ~/ will move home." (defvar ivy--exhibit-timer nil) -(let (last-pos) - (defun ivy-input-changed? () - (let* ((pos (line-end-position)) - (changed (not (eq pos last-pos)))) - (setq last-pos pos) - changed))) +(defalias 'ivy-input-changed-p + (let (last-pos) + (lambda () + (let ((pos (line-end-position))) + (prog1 (not (eql pos last-pos)) + (setq last-pos pos)))))) (defun ivy--queue-exhibit () "Insert Ivy completions display, possibly after a timeout for @@ -3240,7 +3240,7 @@ 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-input-changed?)) + (ivy-input-changed-p)) (progn (when ivy--exhibit-timer (cancel-timer ivy--exhibit-timer)) (setq ivy--exhibit-timer From 78891027dac22705ae65c9b4bc42da41f31683a4 Mon Sep 17 00:00:00 2001 From: 1nc0n Date: Sat, 19 Sep 2020 22:18:24 +0100 Subject: [PATCH 3/3] style-change and refine more-chars case in ivy-input-change-p also added documentation to ivy-input-change-p added doc string and consistency fix --- ivy.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/ivy.el b/ivy.el index 115949e0..2446fce4 100644 --- a/ivy.el +++ b/ivy.el @@ -3228,11 +3228,20 @@ Otherwise, ~/ will move home." (defvar ivy--exhibit-timer nil) (defalias 'ivy-input-changed-p - (let (last-pos) - (lambda () - (let ((pos (line-end-position))) - (prog1 (not (eql pos last-pos)) - (setq last-pos pos)))))) + (let (last-len) + (lambda () + (let ((len (length ivy-text)) + (more-chars-len (ivy-alist-setting ivy-more-chars-alist))) + (prog1 (cond ((< len more-chars-len) + ;; force ui update, changed + nil) + (t ;; changed if len is different + (not (eql len last-len)))) + (setq last-len len))))) + "Return t when lenght of `ivy-text' is changed, +But force return nil when current `ivy-text' len is smaller than `(ivy-alist-setting ivy-more-chars-alist)'. +This closure function stores a previous `ivy-text' length.") + (defun ivy--queue-exhibit () "Insert Ivy completions display, possibly after a timeout for