branch: externals/ivy
commit 5e93415b8116952ed6216b9a2e907733200b1f88
Author: Basil L. Contovounesios <ba...@contovou.net>
Commit: Basil L. Contovounesios <ba...@contovou.net>

    Fix ivy-completion-in-region sole match exit
    
    * ivy.el (ivy-completion-in-region): Determine no/sole match based
    on completion-try-completion result, not completion-all-completions.
    Heed completion-fail-discreetly and completion-show-inline-help and
    use minibuffer-message for consistency with vanilla completion.
    Move point to end and call exit-function on sole match.
    
    Fixes #2946.
---
 ivy.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/ivy.el b/ivy.el
index 5f8e608ace..419d898491 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2697,12 +2697,16 @@ See `completion-in-region' for further information."
          (ivy--minibuffer-table collection)
          (ivy--minibuffer-pred predicate))
     (when last (setcdr last ()))
-    (cond ((null comps)
-           (message "No matches")
+    (cond ((not try)
+           (and (not completion-fail-discreetly)
+                completion-show-inline-help
+                (minibuffer-message "No matches"))
            nil)
-          ((and (null (cdr comps))
-                (string= str (car comps)))
-           (message "Sole match")
+          ((eq try t)
+           (goto-char end)
+           (let ((minibuffer-completion-table collection)
+                 (minibuffer-completion-predicate predicate))
+             (completion--done str 'finished "Sole match"))
            t)
           (t
            (when (eq collection 'crm--collection-fn)

Reply via email to