branch: master
commit 897a39c83852ce7fbedff9a0a066f53d700f82a8
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>

    ivy.el (ivy-completion-in-region): Fix up
    
    There was a bug when no candidates.
---
 ivy.el | 72 +++++++++++++++++++++++++++++++++---------------------------------
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/ivy.el b/ivy.el
index f04ff42..8279e09 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2002,47 +2002,47 @@ See `completion-in-region' for further information."
          (completion-ignore-case case-fold-search)
          (comps
           (completion-all-completions str collection predicate (- end start)))
-         (len (min (ivy-completion-common-length (car comps))))
-         (initial (if (= len 0)
-                      ""
-                    (substring str (- len))))
          (ivy--prompts-list (if (window-minibuffer-p)
                                 ivy--prompts-list
                               '(ivy-completion-in-region (lambda nil)))))
     (if (null comps)
         (message "No matches")
-      (nconc comps nil)
-      (delete-region (- end len) end)
-      (setq ivy-completion-beg (- end len))
-      (setq ivy-completion-end ivy-completion-beg)
-      (if (null (cdr comps))
-          (if (string= str (car comps))
-              (message "Sole match")
-            (unless (minibuffer-window-active-p (selected-window))
-              (setf (ivy-state-window ivy-last) (selected-window)))
-            (ivy-completion-in-region-action
-             (substring-no-properties
-              (car comps))))
-        (let* ((w (1+ (floor (log (length comps) 10))))
-               (ivy-count-format (if (string= ivy-count-format "")
-                                     ivy-count-format
-                                   (format "%%-%dd " w)))
-               (prompt (format "(%s): " str)))
-          (and
-           (ivy-read (if (string= ivy-count-format "")
-                         prompt
-                       (replace-regexp-in-string "%" "%%" prompt))
-                     ;; remove 'completions-first-difference face
-                     (mapcar #'substring-no-properties comps)
-                     :predicate predicate
-                     :initial-input initial
-                     :action #'ivy-completion-in-region-action
-                     :unwind (lambda ()
-                               (unless (eq ivy-exit 'done)
-                                 (goto-char ivy-completion-beg)
-                                 (insert initial)))
-                     :caller 'ivy-completion-in-region)
-           t))))))
+      (let* ((len (ivy-completion-common-length (car comps)))
+             (initial (if (= len 0)
+                          ""
+                        (substring str (- len)))))
+        (nconc comps nil)
+        (delete-region (- end len) end)
+        (setq ivy-completion-beg (- end len))
+        (setq ivy-completion-end ivy-completion-beg)
+        (if (null (cdr comps))
+            (if (string= str (car comps))
+                (message "Sole match")
+              (unless (minibuffer-window-active-p (selected-window))
+                (setf (ivy-state-window ivy-last) (selected-window)))
+              (ivy-completion-in-region-action
+               (substring-no-properties
+                (car comps))))
+          (let* ((w (1+ (floor (log (length comps) 10))))
+                 (ivy-count-format (if (string= ivy-count-format "")
+                                       ivy-count-format
+                                     (format "%%-%dd " w)))
+                 (prompt (format "(%s): " str)))
+            (and
+             (ivy-read (if (string= ivy-count-format "")
+                           prompt
+                         (replace-regexp-in-string "%" "%%" prompt))
+                       ;; remove 'completions-first-difference face
+                       (mapcar #'substring-no-properties comps)
+                       :predicate predicate
+                       :initial-input initial
+                       :action #'ivy-completion-in-region-action
+                       :unwind (lambda ()
+                                 (unless (eq ivy-exit 'done)
+                                   (goto-char ivy-completion-beg)
+                                   (insert initial)))
+                       :caller 'ivy-completion-in-region)
+             t)))))))
 
 (defcustom ivy-do-completion-in-region t
   "When non-nil `ivy-mode' will set `completion-in-region-function'."

Reply via email to