branch: elpa/bash-completion
commit 0f3f8c22b438f1e36e05bc65965231ddc192863c
Author: Stephane Zermatten <[email protected]>
Commit: Stephane Zermatten <[email protected]>
Add a space after a single custom completion.
Before this commit, bash-completion.el only added a space when there was
one completion candidate for default completion. This commit enables
that behavior for custom completion.
No space should be added when the completion ends with a special
character, such as =, for command-line arguments or /, for directories.
---
bash-completion-test.el | 31 +++++++++++++++++++++++++++++++
bash-completion.el | 2 +-
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/bash-completion-test.el b/bash-completion-test.el
index 64a902e1cf..a9f18d6b71 100644
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -876,4 +876,35 @@ before calling `bash-completion-dynamic-complete-nocomint'.
(equal '(17 20 ("./world "))
(bash-completion-dynamic-complete-nocomint 3 (point))))))
+(ert-deftest bash-completion-single-custom-completion ()
+ (--with-fake-bash-completion-send
+ (setq bash-completion-alist '(("ls" "compgen" "args")))
+ (push "--escape\n" --send-results)
+ (insert "$ ls --esc")
+ (let ((bash-completion-nospace nil))
+ (should (equal
+ '("--escape ")
+ (nth 2 (bash-completion-dynamic-complete-nocomint 3
(point))))))))
+
+(ert-deftest bash-completion-single-custom-completion-with-wordbreak-end ()
+ (--with-fake-bash-completion-send
+ (setq bash-completion-alist '(("ls" "compgen" "args")))
+ (push "--color=\n" --send-results)
+ (insert "$ ls --col")
+ (let ((bash-completion-nospace nil))
+ (should (equal
+ '("--color=")
+ (nth 2 (bash-completion-dynamic-complete-nocomint 3
(point))))))))
+
+(ert-deftest bash-completion-single-custom-completion-as-directory ()
+ (--with-fake-bash-completion-send
+ (setq bash-completion-alist '(("ls" "compgen" "args")))
+ (push "somedir/\n" --send-results)
+ (insert "$ ls some")
+ (let ((bash-completion-nospace nil))
+ (should (equal
+ '("somedir/")
+ (nth 2 (bash-completion-dynamic-complete-nocomint 3
(point))))))))
+
+
;;; bash-completion_test.el ends here
diff --git a/bash-completion.el b/bash-completion.el
index 9457499925..6b644bcbf2 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -816,7 +816,7 @@ for directory name detection to work."
(setq suffix "/"))
((and (not open-quote)
(or (eq completion-type 'command)
- (and (memq completion-type '(default wordbreak))
+ (and (memq completion-type '(default wordbreak custom))
single)))
(setq suffix (if bash-completion-nospace "" " ")))))