branch: externals/ivy
commit dda3649f70f6b8eb00efd085d2edf956538c3d80
Merge: c691144be6 078dcc713e
Author: Basil L. Contovounesios <[email protected]>
Commit: Basil L. Contovounesios <[email protected]>
Merge branch 'master' into externals/ivy
---
ivy-test.el | 3 ++-
ivy.el | 28 ++++++++--------------------
2 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index f850bbe736..5cb8de007d 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1010,7 +1010,8 @@ Since `execute-kbd-macro' doesn't pick up a let-bound
`default-directory'.")
(mapc (lambda (pair)
(dolist (str (cdr pair))
(ert-info ((format "%S" str) :prefix "String: ")
- (should (= (ivy-completion-common-length str) (car pair))))))
+ (should (= (with-no-warnings (ivy-completion-common-length str))
+ (car pair))))))
'((0 ""
#("a" 0 1 (face completions-first-difference))
#("ab" 0 1 (face completions-first-difference))
diff --git a/ivy.el b/ivy.el
index 4c8e9d92cb..35cbcfe067 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2668,6 +2668,7 @@ Typically the completion-matching parts of STR have
previously been
propertized by `completion-all-completions', but then the base-size
returned by that function should be preferred over
`ivy-completion-common-length'."
+ (declare (obsolete "it is no longer used." "0.15.1"))
(let* ((char-property-alias-alist '((face font-lock-face)))
(cmn (length str))
(i cmn))
@@ -2693,16 +2694,18 @@ See `completion-in-region' for further information."
(try (completion-try-completion str collection predicate reg md))
(comps (completion-all-completions str collection predicate reg md))
(last (last comps))
- (base-size (cdr last))
+ (base-size (or (cdr last) 0))
(ivy--minibuffer-table collection)
(ivy--minibuffer-pred predicate))
(when last (setcdr last ()))
- (cond ((not try)
+ ;; For no/sole match:
+ ;; give priority to boolean `try', falling back on `comps'.
+ (cond ((not (and try (or (eq try t) comps)))
(and (not completion-fail-discreetly)
completion-show-inline-help
(minibuffer-message "No matches"))
nil)
- ((eq try t)
+ ((and try (or (eq try t) (equal (list str) comps)))
(goto-char end)
(let ((minibuffer-completion-table collection)
(minibuffer-completion-predicate predicate))
@@ -2711,23 +2714,8 @@ See `completion-in-region' for further information."
(t
(when (eq collection 'crm--collection-fn)
(setq comps (delete-dups comps)))
- (let* ((cmn (ivy-completion-common-length (car comps)))
- ;; Translate a 'not found' result to 0. Do this here
(instead
- ;; of fixing `ivy-completion-common-length') for backward
- ;; compatibility, since it's a potentially public function.
- (cmn (if (= cmn (length (car comps))) 0 cmn))
- (initial (cond (base-size (substring str base-size))
- ;; The remaining clauses should hopefully
never
- ;; be taken, since they rely on
- ;; `ivy-completion-common-length'.
- ((= cmn 0)
- "")
- ((>= cmn reg)
- (setq cmn reg)
- str)
- (t
- (substring str (- cmn)))))
- (base-pos (if base-size (+ start base-size) (- end cmn))))
+ (let ((initial (substring str base-size))
+ (base-pos (+ start base-size)))
(delete-region base-pos end)
(setq ivy-completion-beg base-pos)
(setq ivy-completion-end ivy-completion-beg)