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

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

[elpa] externals/vertico 5e5192f 2/6: Improve prompt selection


From: Protesilaos Stavrou
Subject: [elpa] externals/vertico 5e5192f 2/6: Improve prompt selection
Date: Thu, 8 Apr 2021 11:54:23 -0400 (EDT)

branch: externals/vertico
commit 5e5192fbcbee314e056f2db356aedd9f6187db0c
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Improve prompt selection
    
    Do not select the prompt if the first candidate equals the input after the
    completion boundary. This avoids jumping between candidate and prompt. A
    candidate matching the input after the completion boundary will always be 
moved
    first. This is a refinement of the previous commit, see #4. It is getting a 
bit
    complicated unfortunately. Thank you for talking me into this, @oantolin...
---
 vertico.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/vertico.el b/vertico.el
index 0f47f8e..6aba323 100644
--- a/vertico.el
+++ b/vertico.el
@@ -282,12 +282,14 @@
                  (idx (seq-position candidates old)))
            ;; Update index, when kept candidate is found in new candidates 
list.
            (setq vertico--index idx)
-         ;; Otherwise select the prompt for matching inputs or missing 
candidates.
+         ;; Otherwise select the prompt for missing candidates or matching 
inputs,
+         ;; except if the input matches the first candidate.
          (setq vertico--keep nil
                vertico--index
                (if (or (not candidates)
-                       (test-completion input minibuffer-completion-table
-                                        minibuffer-completion-predicate))
+                       (and (not (equal (vertico--input-after-boundary input) 
(car candidates)))
+                            (test-completion input minibuffer-completion-table
+                                             minibuffer-completion-predicate)))
                    -1 0))))
      (setq vertico--base base
            vertico--input input



reply via email to

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