summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2021-08-09 09:08:41 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2021-08-09 09:08:41 +0200
commit92c5ad1543ddd6c12fdaeee4cbb3eeaaa5860049 (patch)
tree812efbfaf5541a6f58bf76cd09f579bc49886c76
parentdcb299905721857d19ef741a246b7149026de8c1 (diff)
Avoid recomputation for empty input (See #48)avoid-empty-recompute
-rw-r--r--corfu.el11
1 files changed, 7 insertions, 4 deletions
diff --git a/corfu.el b/corfu.el
index 9d5403b..571164e 100644
--- a/corfu.el
+++ b/corfu.el
@@ -638,7 +638,10 @@ completion began less than that number of seconds ago."
(pt (- (point) beg))
(str (buffer-substring-no-properties beg end))
(metadata (completion-metadata (substring str 0 pt) table pred))
- (initializing (not corfu--input)))
+ (initializing (not corfu--input))
+ (continue (or (/= beg end)
+ (corfu--match-symbol-p corfu-continue-commands
+ this-command))))
(when corfu--overlay
(delete-overlay corfu--overlay)
(setq corfu--overlay nil))
@@ -651,7 +654,8 @@ completion began less than that number of seconds ago."
;; For example dabbrev throws error "No dynamic expansion ... found".
;; TODO Report this as a bug? Are completion tables supposed to throw errors?
((condition-case err
- (unless (equal corfu--input (cons str pt))
+ ;; Only recompute when input changed and when input is non-empty
+ (when (and continue (not (equal corfu--input (cons str pt))))
(corfu--update-candidates str metadata pt table pred)
nil)
(t (message "%s" (error-message-string err))
@@ -661,8 +665,7 @@ completion began less than that number of seconds ago."
nil)
((and corfu--candidates ;; 2) There exist candidates
(not (equal corfu--candidates (list str))) ;; & Not a sole exactly matching candidate
- (or (/= beg end) ;; & Input is non-empty or continue command
- (corfu--match-symbol-p corfu-continue-commands this-command)))
+ continue) ;; & Input is non-empty or continue command
(corfu--show-candidates beg end str metadata) ;; => Show candidates popup
t)
;; 3) When after `completion-at-point/corfu-complete', no further completion is possible and the