branch: elpa/magit
commit 7167f70665145951c731d7caf9ec39bba4bcbd68
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    magit-completing-read-multiple: Add default to table if necessary
    
    For some completion frameworks we do not display the default in the
    prompt because they immediately highlight the default.  This does not
    work when using `completing-read-multiple' and the default is not a
    member of the collection.  `completing-read' does not have this issue.
---
 lisp/magit-base.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lisp/magit-base.el b/lisp/magit-base.el
index 5a502edf6c7..3e4c3191bce 100644
--- a/lisp/magit-base.el
+++ b/lisp/magit-base.el
@@ -687,6 +687,14 @@ third-party completion frameworks."
                      (equal omit-nulls t))
             (setq input string))
           (funcall split-string string separators omit-nulls trim)))
+       ;; Add the default to the table if absent, which is necessary
+       ;; because we don't add it to the prompt for some frameworks.
+       (table (if (and def
+                       (listp table)
+                       (not (listp (car table)))
+                       (not (member def table)))
+                  (cons def table)
+                table))
        ;; Prevent `BUILT-IN' completion from messing up our existing
        ;; order of the completion candidates. aa5f098ab
        (table (magit--completion-table table))

Reply via email to