[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vertico a8420acdbb 2/2: Improve single candidate behavi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/vertico a8420acdbb 2/2: Improve single candidate behavior |
Date: |
Thu, 19 May 2022 13:57:55 -0400 (EDT) |
branch: externals/vertico
commit a8420acdbbadd190cdddc173e9f37221e2ffb676
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Improve single candidate behavior
- vertico-insert: Insert single candidate even if not selected
- vertico-exit: Never insert single candidate if not selected
---
vertico.el | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/vertico.el b/vertico.el
index 998a4e083f..d7273847b2 100644
--- a/vertico.el
+++ b/vertico.el
@@ -672,7 +672,8 @@ The function is configured by BY, BSIZE, BINDEX, BPRED and
PRED."
(defun vertico-exit (&optional arg)
"Exit minibuffer with current candidate or input if prefix ARG is given."
(interactive "P")
- (unless arg (vertico-insert))
+ (when (and (not arg) (>= vertico--index 0))
+ (vertico-insert))
(when (vertico--match-p (minibuffer-contents-no-properties))
(exit-minibuffer)))
@@ -721,8 +722,9 @@ When the prefix argument is 0, the group order is reset."
;; candidate only includes the prefix "~/emacs/master/lisp/", but not the
;; suffix "/calc". Default completion has the same problem when selecting in
;; the *Completions* buffer. See bug#48356.
- (when (>= vertico--index 0)
- (insert (prog1 (vertico--candidate) (delete-minibuffer-contents)))))
+ (when (or (>= vertico--index 0) (= vertico--total 1))
+ (let ((vertico--index (max 0 vertico--index)))
+ (insert (prog1 (vertico--candidate) (delete-minibuffer-contents))))))
(defun vertico--candidate (&optional hl)
"Return current candidate string with optional highlighting if HL is
non-nil."